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 copying data without knowing location arunsoods DFSORT/ICETOOL 6 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 18 Thu Jul 13, 2017 2:11 pm
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts NDM syntax checking without actually ... GAPX1 All Other Mainframe Topics 0 Wed Jun 07, 2017 2:36 am


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