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
 
Regarding mass insert in table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Regarding mass insert in table
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    Post subject:
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    Post subject: Re: Regarding mass insert in table
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    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 Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am
No new posts Adding a userid to SMTP Security table Yolanda Harvey JCL & VSAM 1 Sun Aug 13, 2017 6:16 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm

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