PL/SQL (MOSC)

MOSC Banner

INSERT with SUBQUERY in VALUES clause

edited Dec 2, 2014 2:34AM in PL/SQL (MOSC) 6 commentsAnswered

i am reading everywhere that subquery cant be used in the value clause of an insert statement . I did some tests and if i use just one column than the subquery succeeds in value clause but for more than one column i am getting error , plz zee below . Can someone explain this behaviour ? thanks SQL>


SQL> CREATE TABLE TEST (ID INT , VALUE INT);

Table created.

CREATE TABLE NEW_TEST  AS SELECT * FROM TEST;

Table created.

SQL> INSERT INTO TEST VALUES (1,3); 1 row created.

SQL> COMMIT;

SQL> INSERT INTO NEW_TEST (ID,VALUE) VALUES((SELECT ID,VALUE FROM TEST WHERE ID> 1)); INSERT INTO NEW_TEST (ID,VALUE) VALUES((SELECT ID,VALUE FROM TEST WHERE ID>1))                                 * ERROR at line 1: ORA-00947: not enough values

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center