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

INSERT WITH SUBSTR


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
No new posts Identify Program Insert DB2 7
No new posts Insert trailer for non empty file only DFSORT/ICETOOL 6
No new posts Merge files with a key and insert a b... DFSORT/ICETOOL 6
Search our Forums:

Back to Top