Home > Database > Mysql Tutorial > Why Am I Getting an ORA-00936 Error with My Oracle 11g INSERT SELECT Statement?

Why Am I Getting an ORA-00936 Error with My Oracle 11g INSERT SELECT Statement?

Susan Sarandon
Release: 2024-12-29 17:50:11
Original
625 people have browsed it

Why Am I Getting an ORA-00936 Error with My Oracle 11g INSERT SELECT Statement?

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;
Copy after login

Therefore, the statement should be modified as follows:

INSERT INTO table1 (col1, col2)
SELECT t1.col1, t2.col2
FROM oldtable1 t1, oldtable2 t2;
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template