【发布时间】:2020-04-29 21:40:19
【问题描述】:
我正在使用 Ora2Pg 工具从 Oracle 迁移到 Postgresql。我的甲骨文代码是
for rec_site in (select regexp_substr(p_site, '[^,]+', 1, level) site
from dual
connnect by regexp_substr(p_site, '[^,]+', 1, level) is not null)
loop
该工具已将此连接转换为之前的 postgresql 脚本。
for rec_site in (WITH RECURSIVE cte AS (
select (SELECT array_to_string(a, '') FROM regexp_matches(p_site, '[^,]+', 'g') AS foo(a) LIMIT 1 OFFSET (level - 1)) site
(SELECT array_to_string(a, '') FROM regexp_matches(p_site, '[^,]+', 'g') AS foo(a) LIMIT 1 OFFSET (level - 1)) is not null
UNION ALL
select (SELECT array_to_string(a, '') FROM regexp_matches(p_site, '[^,]+', 'g') AS foo(a) LIMIT 1 OFFSET (level - 1)) site
SELECT array_to_string(a, '') FROM regexp_matches(p_site, '[^,]+', 'g') AS foo(a) LIMIT 1 OFFSET (level - 1)) is not null JOIN cte c ON ()
) SELECT * FROM cte;
) loop
这段代码给了我语法错误。 SQL 表达式末尾缺少“LOOP”。
【问题讨论】:
-
您遇到的语法错误到底是什么?
-
这是一个 pl/pgsql 脚本吗?你能尝试使用一致的缩进和大小写吗?这将有助于发现语法错误。
标签: postgresql