Troubleshooting INSERT SELECT Statement in Oracle 11G
When attempting to execute an INSERT SELECT statement in Oracle 11G, you may encounter an "ORA-00936: missing expression" error. This error typically indicates an issue with the syntax of the statement.
To resolve this issue, inspect the statement carefully. One common mistake is including the VALUES keyword in the INSERT SELECT statement. In Oracle, the VALUES keyword is only used when inserting explicit values into a table, not when selecting values from another table.
The correct syntax for an INSERT SELECT statement is:
INSERT INTO table_name (column_list) SELECT column_list FROM source_table;
Therefore, the statement should be modified as follows:
INSERT INTO table1 (col1, col2) SELECT t1.col1, t2.col2 FROM oldtable1 t1, oldtable2 t2;
This corrected syntax should successfully execute the Cartesian join between oldtable1 and oldtable2 and insert the resulting rows into table1.
The above is the detailed content of Why Am I Getting an ORA-00936 Error with My Oracle 11g INSERT SELECT Statement?. For more information, please follow other related articles on the PHP Chinese website!