View previous topic :: View next topic |
Author |
Message |
prog_mario Beginner
Joined: 08 Sep 2007 Posts: 86 Topics: 27
|
Posted: Sun Dec 05, 2010 10:26 am Post subject: What format (pic) DB2 uses when we compare columns. |
|
|
Hi everyone.
I have a query in a unload step like the one bellow and I don't know what format column_result1 will be by default.
I know that when I perform a select count(*) into a variable it can be a
S9(4) comp in cobol.
Select column_A,
case(when column_B = column_T) then 1 else 0 end as column_result1
from table_1;
If someone could tell me about db2 manuals in which I can find more detailed information on that, I would thank a lot. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Sun Dec 05, 2010 3:40 pm Post subject: |
|
|
prog_mario,
IIRC , it would be a integer. However you can force the type and length of the target field.
untested sql
Code: |
Select column_A
,case when column_B = column_T
then int(1) else int(0) end as column_result1
from table;
|
or
Code: |
Select column_A
,case when column_B = column_T
then dec(1) else dec(0) end as column_result1
from table;
|
or
Code: |
Select column_A
,case when column_B = column_T
then smallint(1) else smallint(0) end as column_result1
from table;
|
or
Code: |
Select column_A
,case when column_B = column_T
then char('1') else char('0') end as column_result1
from table;
|
Kolusu |
|
Back to top |
|
|
prog_mario Beginner
Joined: 08 Sep 2007 Posts: 86 Topics: 27
|
Posted: Mon Dec 06, 2010 6:36 am Post subject: |
|
|
I'm going to test the queries you suggested.
Sorry but what's IIRC?
Thank you Kolusu. _________________ The more I learn, the more I want to learn. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Mon Dec 06, 2010 11:28 am Post subject: |
|
|
prog_mario wrote: | Sorry but what's IIRC? |
I was just too lazy to type "If I Remember Correctly"
Kolusu |
|
Back to top |
|
|
prog_mario Beginner
Joined: 08 Sep 2007 Posts: 86 Topics: 27
|
Posted: Mon Dec 06, 2010 5:44 pm Post subject: |
|
|
Kkkkk. That's really cool.
Thanks again.
And hope you all have a nice week. _________________ The more I learn, the more I want to learn. |
|
Back to top |
|
|
|
|