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 

Batch DB2 Unload

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


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

PostPosted: Thu Jul 28, 2005 12:05 pm    Post subject: Batch DB2 Unload Reply with quote

I have a file that is in the format XXX YYY which I need to duplicate using a DB2 batch utility. If I use DSNTIAUL and say SELECT COL1, COL2 FROM MY.TABLE, the resulting file is in the format XXXYYY, that is, without the space. If I say SELECT COL1, ' ', COL2 FROM MY.TABLE, the resulting file is in the format XXX.. YYY where .. is the length attribute.

Is there a way of creating this file in the correct format?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 28, 2005 12:17 pm    Post subject: Reply with quote

Bithead,

yes you can create it in the desired format. When you use a simple space, the unload utility treates it as varchar and pads the extra 2 bytes when unloading. so you need to use the function CHAR to avoid the extra 2 bytes.

i.e

Code:

SELECT COL1
      ,CHAR(' ')
      ,COL2
  FROM TABLE
 ;


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
Bithead
Advanced


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

PostPosted: Thu Jul 28, 2005 12:19 pm    Post subject: Reply with quote

Thanks Kolusu. That worked great.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 28, 2005 12:23 pm    Post subject: Reply with quote

Bithead,

Glad that worked. If you want N spaces between the 2 columns, you can simply specify it on the char function as shown below.

Code:

SELECT COL1
      ,CHAR(' ',N)
      ,COL2
  FROM TABLE
 ;


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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