Where not exists causing problems for insert into, db2
db2
Solution
This will work:
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);
An alternative to sysibm.sysdummy1 would be:
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);
Problem
I have a query like so: ``` insert into mySchema.myTable (award_id, cust_id) values ('blahblah', 12345) where not exists (select * from mySchema.myOtherTable where cust_id = 12345); ``` I am getting error: ``` ILLEGAL USE OF KEYWORD WHERE. TOKEN FOR <END-OF-STATEMENT> NOT ATOMIC WAS EXPECTED SQL Code: -199, SQL State: 42601 ``` I have seen a bunch of similar queries accepted as answers, and I don't understand why it's finding issue with this.