引用符付きテーブル識別子を使用する場合、一般的な構文エラーはInformixのQueryによる接続から発生しました
-
21-12-2019 - |
質問
Informixデータベースで次のクエリを実行すると、データベースは一般的な構文エラー(問題を引き起こすものに対して表示なし)を報告します。同じクエリはCubridまたはOracleデータベースで完全に実行されます。どちらもCONNECT BY
構文をサポートします。
select
lower(connect_by_root "t_directory"."name"),
connect_by_isleaf,
connect_by_iscycle,
substr(
sys_connect_by_path(lower("t_directory"."name"), '/'),
2) "dir"
from "t_directory"
start with "t_directory"."parent_id" is null
connect by nocycle prior "t_directory"."id" = "t_directory"."parent_id"
order siblings by lower("t_directory"."name") asc
.
データベースを使用しているデータベースは、Windows上のInformix 12.10の開発版です。次の接続URLを使用してJDBCドライバからクエリを実行しています(引用符で囲まれた表識別子を許可します)。
jdbc:informix-sqli://localhost:9092/test:INFORMIXSERVER=ol_informix;DELIMIDENT=y
. 解決
ここでの正確な問題は、prior
が引用符付きテーブル識別子を受け入れないという事実ですが、引用符で列の識別子は大丈夫です。このクエリは完全にうまく動作します。
select
lower(connect_by_root "t_directory"."name"),
connect_by_isleaf,
connect_by_iscycle,
substr(
sys_connect_by_path(lower("t_directory"."name"), '/'),
2) "dir"
from "t_directory"
start with "t_directory"."parent_id" is null
connect by nocycle prior t_directory."id" = "t_directory"."parent_id"
order siblings by lower("t_directory"."name") asc
.
...違いがあると:
-- Bad:
connect by nocycle prior "t_directory"."id" = "t_directory"."parent_id"
-- Good:
connect by nocycle prior t_directory."id" = "t_directory"."parent_id"
. 所属していません StackOverflow