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
 

 

INSERT WITH SUBSTR

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

New User


Joined: 06 Mar 2006
Posts: 35

PostPosted: Fri Mar 24, 2006 2:12 am    Post subject: INSERT WITH SUBSTR
Reply with quote

Hi,

I have a table with 5000 rows in it. Iam trying to add that data as a single row into another table.
Is there a way i can loop in the select stamenent and subtring it.

Ex: select testchar from test_table1;

ravi
madhu
kiran

three rows selected

i would like to insert this data as a single row in another table like this

ravi madhu kiran

is there a way i can do this through simple SQL(insert and select with substr).

thanks,
Ganapath
Back to top
View user's profile Send private message

KS

New User


Joined: 28 Feb 2006
Posts: 91
Location: Chennai

PostPosted: Fri Mar 24, 2006 9:59 am    Post subject: Re: INSERT WITH SUBSTR
Reply with quote

SELECT A.TEST_CHAR1,
B.TESTCHAR1,C.TESTCHAR1
FROM TEST_TABLE1 A
TEST_TABLE1 B
TEST_TABLE1 C
WHERE
B.TESTCHAR1 = A.TESTCHAR1
C.TESTCHAR1 = A.TESTCHAR1
AND A.TS_TESTCHAR1 < B.TS_TESTCHAR1
AND B.TS_TESTCHAR1 < C.TS_TESTCHAR1
AND C.TS_TESTCHAR1 < D.TS_TESTCHAR1;

this will concatenate the names .
Write this select query inside the insert query.

Thanks,
KS
Back to top
View user's profile Send private message
jtop

New User


Joined: 30 Mar 2006
Posts: 1

PostPosted: Thu Mar 30, 2006 5:32 am    Post subject: Re: INSERT WITH SUBSTR
Reply with quote

So you want him to write a inner SQL with 5000 joins icon_eek.gif

BTW, what is the joining condition between
B.TESTCHAR1 = A.TESTCHAR1
C.TESTCHAR1 = A.TESTCHAR1

And what table does this D.TESTCHAR1 point to? or is it a typo?
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 Lines in JCL with Rexx after a... Willy Jensen CLIST & REXX 3 Tue Aug 30, 2016 4:18 pm
No new posts How to insert a lengthy string havin... vidyaa DB2 7 Thu Aug 25, 2016 5:20 pm
No new posts How do I right justify a string in an... rakesh17684 DB2 1 Wed Jun 08, 2016 8:01 pm
No new posts insert the same records but chancing ... danylele74 DB2 6 Mon May 02, 2016 7:22 pm
No new posts Can a DB2 insert trigger execution of... TS70363 DB2 6 Tue Nov 24, 2015 10:44 pm


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