View previous topic :: View next topic
|
Author |
Message |
Elixir
Active User
Joined: 08 Feb 2009 Posts: 116 Location: CHENNAI/NEW JERSEY - INDIA/USA
|
|
|
|
Hi,
My aim is to unload a DB2 table onto a file,
The Sysin
------------------------------------
Select Col1,---> 20 bytes
col2,---->20 bytes
col3,-->2 bytes
case col4
when '*' then 'star'
end
from table1, table2, table 3
------------------------------------
On unloading im am getting a Lowvalue(X'00') and a X'0F' between col3 and col4 in the output unload file.
Please let me know if any addional statement need to be used if we use CASE statement while unloading data from table. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
how about case col4 when '*' then 'STAR' otherwise col4 end
is col4 char or varchar?
what is the length of col4? 15 perchance? |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
DSNTIAUL treats a literal as a VARCHAR. The extra byte you are seeing represents the length of the literal value. (Though the value you cite, x'000F' does not make any sense for the given example).
One way around this is to use the CHAR function. CHAR('STAR',4) should do the trick. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
without "else " in the case the output field will be nullable and thus an extra null-indicator will be added to the output file |
|
Back to top |
|
|
Elixir
Active User
Joined: 08 Feb 2009 Posts: 116 Location: CHENNAI/NEW JERSEY - INDIA/USA
|
|
|
|
dbzTHEdinosauer,
All the Columns are Char.
Col4 is CHAR(1).
Between col3 and output of Case I get the below,
43,44
00
0F
The maximum length of Case output is 15. |
|
Back to top |
|
|
Elixir
Active User
Joined: 08 Feb 2009 Posts: 116 Location: CHENNAI/NEW JERSEY - INDIA/USA
|
|
|
|
Don,
I tried using your suggestion. There is non prepaded values now. Thanks.
But I am confused with the with prepaded X'000F' in case I do not use CHAR in the SYSIN. |
|
Back to top |
|
|
|