Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Inserting data with a subquery, but set 3 cols before

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Inserting data with a subquery, but set 3 cols before
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    Post subject: Re: Inserting data with a subquery, but set 3 cols before
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    Post subject:
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    Post subject: Re: Inserting data with a subquery, but set 3 cols before
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us