我有这样的查询:
insert into mySchema.myTable (award_id, cust_id) values ('blahblah', 12345)
where not exists (select * from mySchema.myOtherTable where cust_id = 12345);
Run Code Online (Sandbox Code Playgroud)
我收到错误:
ILLEGAL USE OF KEYWORD WHERE. TOKEN FOR <END-OF-STATEMENT> NOT ATOMIC WAS EXPECTED SQL
Code: -199, SQL State: 42601
Run Code Online (Sandbox Code Playgroud)
我已经看到一堆类似的查询被接受作为答案,我不明白为什么它会发现这个问题.
这将有效:
insert into mySchema.myTable (award_id, cust_id)
select 'blahblah', 12345
from sysibm.sysdummy1
where not exists (select * from mySchema.myOtherTable where cust_id = 12345);
Run Code Online (Sandbox Code Playgroud)
sysibm.sysdummy1的替代方法是:
insert into mySchema.myTable (award_id, cust_id)
select 'blahblah', 12345
from ( values (1) )
where not exists (select * from mySchema.myOtherTable where cust_id = 12345);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9990 次 |
| 最近记录: |