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 Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm


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