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
 

 

How to Select Spaces using DB2 query

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

New User


Joined: 31 Aug 2009
Posts: 73
Location: Mumbai

PostPosted: Mon Oct 11, 2010 12:57 pm    Post subject: How to Select Spaces using DB2 query
Reply with quote

Hi,
If i have a table say X, which has 10 columns(fields), I want to fetch 5 fields using select clause which i can do,These 5 columns have total lenght of 50, I want it to write in output file, this i can do thru IKJEFT01 utility, but the output file is of 150 length that means 50 lenght i can get from fields of table but remaining 150 fields i want it to write as spaces.
Now 1 way is to do is -
SELECT 5 fields,CHAR( 150 spaces ) FROM table(X) .... But this will cost me to type 150 spaces in CHAR field, Is there anyway to fetch 150 spaces?
Back to top
View user's profile Send private message

apandey

New User


Joined: 31 Aug 2009
Posts: 73
Location: Mumbai

PostPosted: Mon Oct 11, 2010 12:58 pm    Post subject:
Reply with quote

Just to add correction in above query, output file is of 200 length.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1280
Location: Belgium

PostPosted: Mon Oct 11, 2010 2:51 pm    Post subject:
Reply with quote

do you mean repeat(' ',200) ?
Back to top
View user's profile Send private message
apandey

New User


Joined: 31 Aug 2009
Posts: 73
Location: Mumbai

PostPosted: Mon Oct 11, 2010 4:03 pm    Post subject:
Reply with quote

Sorry GuyC, i havent understood ur reply .. But my output file's LRECL is 200 in SYSREC(i m using IKJEFT01). When i will fetch 5 fields, 50 legth's data will written to file(as each field's length is 10), but for remaining 150 length, i want to write space, so how i will fetch that 150 space using select query. 1 way i already mentioned in my 1st post.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Oct 11, 2010 4:14 pm    Post subject:
Reply with quote

Ashutosh,

since you wrote this
Quote:
IKJEFT01 utility
it is not surprising that you do not understand GuyC's solution,
because that would require looking in a manual for the db2 utility that you are invoking thru the terminal monitor program,
or simply knowing sql.
Back to top
View user's profile Send private message
apandey

New User


Joined: 31 Aug 2009
Posts: 73
Location: Mumbai

PostPosted: Mon Oct 11, 2010 5:49 pm    Post subject:
Reply with quote

I got it now .. thanks GuyC .. !!
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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