IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Inserting data with a subquery, but set 3 cols before


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
delago

New User


Joined: 29 Jul 2005
Posts: 21
Location: Brazil

PostPosted: Thu Jan 04, 2007 2:27 am
Reply with quote

Hi guys,

I need some help.
I have a table:
table_1
colum01 CHAR
colum02 INTEGER
colum03 INTEGER
colum04 INTEGER
... <== have more 36 colums next
colum40 CHAR

I need to insert a new row in that table, with some data from another row. The row in the same table too.

I wrote the command, but I receive only message errors. My comand is:
insert into table_01
Values( 'g', 0001, 0001, (select colum04, colum05,....colum40
from table_01
where colum01 = 'x'
and colum02 = 0065
and colum03 = 1001000));


I need to set the 3 first colums and receive from SELECT the another colums.

Somebody know is possible?
Thank for some help.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Jan 04, 2007 3:44 am
Reply with quote

Hello delago,

try this

Code:

  INSERT INTO TABLE_01                 
  SELECT 'G',                         
         0001,                         
         0001,                         
         COLUM04,                     
         COLUM05,                     
         :                             
         :                             
         COLUM40                       
    FROM TABLE_01                     
   WHERE COLUM01 = 'X'                 
     AND COLUM02 = 0065               
     AND COLUM03 = 1001000             
  ;
Back to top
View user's profile Send private message
delago

New User


Joined: 29 Jul 2005
Posts: 21
Location: Brazil

PostPosted: Thu Jan 04, 2007 5:02 pm
Reply with quote

Thank's Dave! icon_lol.gif
This resolved my problem.
Oh!...and HappyNew Year!
Good Job.

Fernando Delago - BR/SP
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Jan 06, 2007 12:14 am
Reply with quote

Glad we could help Fernando,

You have a good 2007 also.

Hope to see more posts from you icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 2
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top