View previous topic :: View next topic |
Author |
Message |
Bithead Advanced
Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Thu Jul 28, 2005 12:05 pm Post subject: Batch DB2 Unload |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Jul 28, 2005 12:17 pm Post subject: |
|
|
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 |
|
|
Bithead Advanced
Joined: 03 Jan 2003 Posts: 550 Topics: 23 Location: Michigan, USA
|
Posted: Thu Jul 28, 2005 12:19 pm Post subject: |
|
|
Thanks Kolusu. That worked great. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Jul 28, 2005 12:23 pm Post subject: |
|
|
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 |
|
|
|
|