While this works as expected:
SQL> DROP TABLE TEST1; Table dropped. SQL> CREATE TABLE TEST1 (COL1 INTEGER, COL2 INTEGER); Table created. SQL> INSERT WHEN 1=1 2 THEN INTO TEST1 (COL1, COL2) 3 SELECT 1, 0 FROM DUAL; 1 row created. SQL>
I receive a strange "ORA-00918: column ambiguously defined" error attempting this with more than two columns:
SQL> DROP TABLE TEST1; Table dropped. SQL> CREATE TABLE TEST1(COL1 INTEGER, COL2 INTEGER, COL3 INTEGER); Table created. SQL> INSERT WHEN 1=1 2 THEN INTO TEST1 (COL1, COL2, COL3) 3 SELECT 1, 0, 0 FROM DUAL; THEN INTO TEST1 (COL1, COL2, COL3) * ERROR at line 2: ORA-00918: column ambiguously defined SQL>
Why am I receiving ORA-00918 errors here? Is there a limit on how many columns I can SELECT in an INSERT WHEN ... THEN INTO ... SELECT pattern?
Note: I'm using Oracle 11.2.0.1.0, and the actual query I'm attempting to execute in production is more complex and references other tables (and using "VALUES" would not suffice). This is just the simplified case...