Subquery in INSERT statement



IBM's flagship relational database management system

Subquery in INSERT statement

Postby unique » Fri May 13, 2011 7:04 pm

Hi

I am trying to insert a row into table with below sql

INSERT INTO OWNER.TABLEA VALUES (VALUE1, VALUE2, VALUE3, SELECT COLUMN1 FROM OWNER.TABLEB)
i am getting the following error. Can you guys help me out?

Can an insert statement consist of both values and subquery?

SNT408I SQLCODE = -104, ERROR:  ILLEGAL SYMBOL "COLUMN1". SOME SYMBOLS   
        THAT MIGHT BE LEGAL ARE: CONCAT || / MICROSECONDS MICROSECOND SECONDS 
        SECOND MINUTES                                                         
SNT418I SQLSTATE   = 42601 SQLSTATE RETURN CODE                               
SNT415I SQLERRP    = DSNHPARS SQL PROCEDURE DETECTING ERROR                   
SNT416I SQLERRD    = 3 0  0  -1  94  502 SQL DIAGNOSTIC INFORMATION           
SNT416I SQLERRD    = X'00000003'  X'00000000'  X'00000000'  X'FFFFFFFF'       
        X'0000005E'  X'000001F6' SQL DIAGNOSTIC INFORMATION                   


Thanks
unique
 
Posts: 1
Joined: Mon Dec 13, 2010 5:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Subquery in INSERT statement

 

Re: Subquery in INSERT statement

Postby GuyC » Fri May 13, 2011 8:21 pm

the answer is NO.

But you can always put values in a select :

INSERT INTO OWNER.TABLEA VALUES (SELECT VALUE1, VALUE2, VALUE3, COLUMN1 FROM OWNER.TABLEB)
I can explain it to you, but i can not understand it for you.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post