このオプションを使用すると、User Queriesで完全修飾されていない名前の解決を有効または無効にできます。
完全修飾されていない名前の解決は、テーブル、ビュー、およびストアドプロシージャに適用されます。以下、これらのエンティティをリソースまたはグループシンボルと呼びます。
Enabling Non-Fully Qualified Names Resolution
完全修飾されていない名前解決を有効にするには、現在のセッションで有効にするか、グローバルに有効にするかによって、SET
文を使用する方法と、 SYSADMIN.setDefaultOptionValue()
ストアドプロシージャを呼び出す方法があります。
Using SET Statement
この場合、オプションは現在のセッションでのみ有効になります。
以下の例では、 SET
ステートメントを使用して名前解決を有効にしています:
SET
$NAME_RESOLUTION_ORDER
"test_tables_pg, test_tables"
;;
SET
$NAME_RESOLUTION_ORDER
"*"
;;
SET
$NAME_RESOLUTION_ORDER
"-"
;;
Using Stored Procedure
この場合、オプションはグローバルに設定されます。
以下の例では、ストアドプロシージャを呼び出して名前解決を有効にしています:
CALL SYSADMIN.setDefaultOptionValue(
"opt"
=>
'NAME_RESOLUTION_ORDER'
,
"val"
=>
'-'
);;
CALL SYSADMIN.setDefaultOptionValue(
"opt"
=>
'NAME_RESOLUTION_ORDER'
,
"val"
=>
'*'
);;
CALL SYSADMIN.setDefaultOptionValue(
"opt"
=>
'NAME_RESOLUTION_ORDER'
,
"val"
=>
'schema1, schema2'
);;
CALL SYSADMIN.setDefaultOptionValue(
"opt"
=>
'NAME_RESOLUTION_ORDER'
,
"val"
=>
'schema1, schema2, *'
);
Options
以下の表は、このオプションで使用できる値をまとめたものです:
To view the full table, click the expand button in its top right corner
Option value | Description |
---|---|
- | Fully qualified names are always required; default value |
* | Look in all schemas as in the previous implementation. The main difference is that now the resolution algorithm takes into account also the user rights on the resource and two different error messages ("Group is ambiguous" or "User has no rights") can be shown depending on the number of discovered resources accessible to the user. Some examples will be shown in the next section. |
<comma separated list of schemas> | Look in these schemas exactly in this order. If the resource is defined in more than one schema provided in the list, the name will be resolved using the first schema in the order containing the resource; if the resource is not defined in these schemas, the system will throw a "Table/View/Proc/ not found..." exception. More examples will be shown in the following section. |
<comma separated list of schema> + "*" symbol | Look in these schemas as for the previous option. If the resource is defined in none of these schemas but it is defined multiple times in other schemas, the system will throw a "Group specified is ambiguous..." error. |
Usage Examples
次の表は、SELECT * FROM <non-fully qualified table name>
のようなクエリを実行したときのシステムの動作の例をいくつか示しています(この表はすべての可能な組み合わせを網羅しているわけではありません):
To view the full table, click the expand button in its top right corner
NAME_RESOLUTION_ORDER | sch1 | Rights on sch1 | sch2 | Rights on sch2 | schX | Rights on schX | schY | Rights on schY | Result |
---|---|---|---|---|---|---|---|---|---|
| The query always fails if the table name is not fully qualified | ||||||||
| sch2 | ||||||||
| "No permissions..." error | ||||||||
| sch1 | ||||||||
| sch2 | ||||||||
| "Table not found" error | ||||||||
| "Table not found" error | ||||||||
| sch1 | ||||||||
| sch1 | ||||||||
| sch2 | ||||||||
| sch1 | ||||||||
| schX | ||||||||
| "Group specified is ambiguous..." error | ||||||||
| "Table not found" error | ||||||||
| "Table not found" error | ||||||||
| "Group specified is ambiguous..." error | ||||||||
| "No permissions..." error | ||||||||
| sch1 |
Legend:
– the schema has no tables with this name
– the schema contains a table with this name
– for the resolution, it does not matter if the schema contains such a table or not
For the rights column:
– no permission
– user has permissions on the schema/table
– does not matter