MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help in sql

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Rmravi
Beginner


Joined: 24 Jun 2004
Posts: 12
Topics: 5

PostPosted: Thu Jul 15, 2004 12:50 am    Post subject: help in sql Reply with quote

I am extracting the data from the table A using the following query.

select * from A;

Result will be like this:

x y z
-------
1 2 3
4 5 5
a b c

But I need the column delimiter '|' between the two columns. I need the ruslt like this

1|2|3
4|5|5
a|b|c

If I write the query like this I can get the above result.
Back to top
View user's profile Send private message
NutCracker
Beginner


Joined: 13 Dec 2002
Posts: 45
Topics: 3
Location: 3rd Block from the SUN

PostPosted: Thu Jul 15, 2004 1:18 am    Post subject: Reply with quote

Code:

SELECT X || '|' AS X, Y ||  '|' AS Y, Z || '|' AS Z
FROM A;


gives the output as you need.

Code:

X|Y|Z
----+-
1|2|3
4|5|5
a|b|c
Back to top
View user's profile Send private message
Rmravi
Beginner


Joined: 24 Jun 2004
Posts: 12
Topics: 5

PostPosted: Thu Jul 15, 2004 1:41 am    Post subject: Reply with quote

But I don't want to select the column list manually in the selection list. (In the real database I am having around 100 columns with different data type).
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12401
Topics: 75
Location: San Jose

PostPosted: Thu Jul 15, 2004 4:40 am    Post subject: Reply with quote

rmravi,

If you have IBM's DB2 High Performance Unload then you can specify the DELIMTED Format. check this link.

http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/INZUGB11/3.2.2.2?SHELF=&DT=20021218173111&CASE=

If your shop does not have the utility then you need to go with Nutcracker's solution.

Hope this helps...

cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rmravi
Beginner


Joined: 24 Jun 2004
Posts: 12
Topics: 5

PostPosted: Thu Jul 15, 2004 5:42 am    Post subject: Reply with quote

Thanks Kolusu
Back to top
View user's profile Send private message
Bithead
Advanced


Joined: 03 Jan 2003
Posts: 550
Topics: 23
Location: Michigan, USA

PostPosted: Thu Jul 15, 2004 7:58 am    Post subject: Reply with quote

You could always run program DSNTEP2 - this gives you similar results.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group