【发布时间】:2022-01-12 15:22:40
【问题描述】:
我正在尝试将 WITH 子句中声明的函数用于 MERGE 语句。 这是我的代码:
create table test
(c1 varchar2(10),
c2 varchar2(10),
c3 varchar2(10));
insert into test(c1, c2) values ('a', 'A');
insert into test(c1, c2) values ('b', 'A');
select * from test;
begin
with function to_upper(val varchar2) return varchar is
begin
return upper(val);
end;
merge into test a
using (select * from test) b
on (upper(a.c1) = upper(b.c2))
when matched then
update set a.c3 = to_upper(a.c1);
end;
但我收到此错误:
错误报告 - ORA-06550:第 2 行,第 15 列:PL/SQL:ORA-00905: 缺少关键字 ORA-06550:第 2 行,第 1 列:PL/SQL:SQL 语句 忽略 ORA-06550:第 6 行,第 1 列:PLS-00103:遇到符号 “合并” 06550. 00000 - “第 %s 行,第 %s 列:\n%s” *原因:通常是 PL/SQL 编译错误。 *行动:
有人能解释一下为什么它不起作用吗?
谢谢,
【问题讨论】:
-
@AlexPoole:我通过添加函数的用法来编辑代码。
标签: sql oracle plsql oracle12c