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 

What format (pic) DB2 uses when we compare columns.

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


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Sun Dec 05, 2010 10:26 am    Post subject: What format (pic) DB2 uses when we compare columns. Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Sun Dec 05, 2010 3:40 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Mon Dec 06, 2010 6:36 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Dec 06, 2010 11:28 am    Post subject: Reply with quote

prog_mario wrote:
Sorry but what's IIRC?


I was just too lazy to type "If I Remember Correctly"

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Mon Dec 06, 2010 5:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
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