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

Regarding mass insert in table


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

New User


Joined: 22 Sep 2006
Posts: 33

PostPosted: Thu Mar 15, 2007 6:16 pm
Reply with quote

hi,

I have a table1 and columns like,

R_cd C_cd C_SRC_CD C_HDR_TY_CD
0014 A 8 1
0014 A 8 2
0025 A 8 C
0025 A 8 E
0025 A 8 K
0025 A 8 L
0025 A 8 M
0025 A 8 P
0025 A 8 S
0025 A 8 T
0025 C 8 C
0025 C 8 E
0025 C 8 H
0025 C 8 I
0025 C 8 K
0025 C 8 L
...................................


Like this I have around 10,000 rows in mytable....

now my requirement is wherever the C_SRC_CD value is '8', I have to insert below 1 row same as above values except C_SRC_CD should be '1' in the pace of 1.....(for reference i have bolded that value '1')

My o/p should be like this......


R_cd C_cd_ C_SRC_CD C_HDR_TY_CD
0014 A 8 1
0014 A 1 1
0014 A 8 2
0014 A 1 2
0025 A 8 C
0025 A 1 C
0025 A 8 E
0025 A 1 E
0025 A 8 K
0025 A 1 K
0025 A 8 L
0025 A 1 L
0025 A 8 M
0025 A 1 M
0025 A 8 P
0025 A 1 P
0025 A 8 S
0025 A 1 S
0025 A 8 T
0025 A 1 T
0025 C 8 C
0025 C 1 C
0025 C 8 E



Can any one please help me throuugh SQL how can I do this.........


It's high priority task plz hepl me........
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Thu Mar 15, 2007 6:27 pm
Reply with quote

I assume C_SRC_CD is Numeric datatype.

INSERT INTO tablename(R_cd,C_cd,C_SRC_CD, C_HDR_TY_CD)
SELECT R_cd,C_cd,1, C_HDR_TY_CD FROM tablename
WHERE C_SRC_CD = 8 ;

If C_SRC_CD is CHAR then put it in quotes.

I have not tested this. Let me know what happens..
Back to top
View user's profile Send private message
santhunaveen

New User


Joined: 22 Sep 2006
Posts: 33

PostPosted: Fri Mar 16, 2007 5:18 pm
Reply with quote

hi,


Thanks it's working.....
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts count contained values of several col... DB2 5
No new posts To join 2 tables and to join 3rd tabl... DB2 8
No new posts Create a specific record/file based o... SYNCSORT 8
No new posts Extract ISPF table column headings CLIST & REXX 2
No new posts Sort to insert record in an empty file. DFSORT/ICETOOL 5
Search our Forums:


Back to Top