Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Insert with Select

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
shashikant

New User


Joined: 07 Sep 2007
Posts: 6
Location: chennai

PostPosted: Fri Nov 13, 2009 9:14 pm    Post subject: Insert with Select
Reply with quote

Hi,

Here is the scenario:
I have a table with 3 columns with primary field as F1
i want to create another set of these rows but with a primary key as B instead of A in column F1,cloning all other columns as with F1= A

Original table : F1=primary key
F1 F2 F3
A D I
A E J
A F K
A G L
A H M
'''''''''''''
'''''''
''
'

Expected table after INSERT

F1 F2 F3
A D I
A E J
A F K
A G L
A H M

B D I
B E J
B F K
B G L
B H M
'''''''''''''
'''''''
''
'
Hope u guys understand what i implied.
Please assist.
Back to top
View user's profile Send private message

sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Sat Nov 14, 2009 5:09 pm    Post subject:
Reply with quote

shashikant,

What you looking for is
Code:
insert into table
select 'B',f2,f3 from table


Not tested.


Sushanth
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Nov 14, 2009 10:06 pm    Post subject:
Reply with quote

Hello,

If you want only rows with F1 = A replicated as Bs, add this to the SELECT:
Code:
   WHERE F1 = 'A'

Without this, all rows in the table will be copied with B as the value for F1.
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 How to insert a value on specific pos... Poha Eater DFSORT/ICETOOL 9 Sun Oct 01, 2017 3:04 am
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us