IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB22 casting to CHAR


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nirav721

New User


Joined: 11 Feb 2008
Posts: 53
Location: NJ

PostPosted: Wed Mar 19, 2008 8:16 pm
Reply with quote

Hi,

I have a dilemma...

I have a decimal(9,2) field and I am using a IFNULL function inside my select to replace null fields with X'FF'. And to do this, I am using casting to CHAR. Now, I am doing cast to CHAR(11) to make sure nothing gets truncated, but my host variable is defined as only PIC X(5)... Is there a way to get around this?

I want to be able to move X'FF' inside the host variable which is PIC X(5) for a DECIMAL(9,2) column when it is NULL?

Any help is appreciated

Thanks
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Mar 19, 2008 8:56 pm
Reply with quote

Why are you trying to sustitute high values for a numeric field even if it is blank? That is what null indicator fields are for. How could you expect to fit a char(11) field into a pic x(5) field?
Back to top
View user's profile Send private message
Nirav721

New User


Joined: 11 Feb 2008
Posts: 53
Location: NJ

PostPosted: Wed Mar 19, 2008 9:10 pm
Reply with quote

I need to move high-values in so that the modules that have already been coded need not be changed... PIC X(5) would be the packed decimal value...?

Hope this clears it a bit..

Also, another question

I know I can do

SELECT CASE <COLUMN>
WHEN <COLUMN> THEN
....
ELSE
....
END

But, what can I put in to do

SELECT CASE <COLUMN>
WHEN not <COLUMN> THEN
....
ELSE
....
END

It is flagging me on the NOT part....

Thanks for the help...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Mar 19, 2008 10:19 pm
Reply with quote

As Craig said, you can't load non numerics to a numeric DB2 column.

even if you could, you would have to turn off the null ind for the column.

please get back if you can accomplish this.

I don't think that you can.

besides X'FF' is not a valid packed-decimal field.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 19, 2008 10:26 pm
Reply with quote

Hello,

You need to rethink the implementation.

Keep in mind that even if you do find a way to force the invalid value into the column, you will be forever trying to get around the problems it will cause when something tries to use it.
Back to top
View user's profile Send private message
Nirav721

New User


Joined: 11 Feb 2008
Posts: 53
Location: NJ

PostPosted: Wed Mar 19, 2008 11:03 pm
Reply with quote

Hi Thanks, yep, I realize it.

So, what I have done now is, I initialize the whole host variable area to high-values, and then do a check such as

CASE WHEN <COLUMN1> IS NOT NULL
IFNULL(<COLUMN1>,0) <-- this does absolutely nothing.
END AS <COLUMN1>

This way, I only move the field in if there is actually value in it, if not, it does not move it inside my host-variable area, leaving X'FF's intact...

What do you guys think?
Back to top
View user's profile Send private message
Nirav721

New User


Joined: 11 Feb 2008
Posts: 53
Location: NJ

PostPosted: Thu Mar 20, 2008 12:46 am
Reply with quote

Actually, I need not even do the last part because DB2 takes care of moving part...All this time I was under the impression that DB2 does move some sort of data when a column is null...but it doesnt..so I need not do anything at all....

Thanks
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 20, 2008 1:05 am
Reply with quote

You're welcome - good luck icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Using PARM=('JPn"&SYMBOL&quo... DFSORT/ICETOOL 2
No new posts Cobol Db2 program (inserting Char Equ... COBOL Programming 0
No new posts COnvert a column with mix of hex ,cha... DB2 5
Search our Forums:

Back to Top