CAST function

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
bolastuff1975
Member
Posts: 8
Joined: Fri Sep 21, 2007 11:03 pm

CAST function

Post by bolastuff1975 » Tue Oct 23, 2007 9:14 pm

Hi,

I have a table with one of the varaibles declared as VARCHAR(4000).

at position 50 for that variable, i have a packed value of s9(9) comp-3

i need to query this table to pick records that have a value of 5000 @ 5.

Sample data in hex format
0004400000
00C000050C

when i use the cast funciton to just select this record i get the below error message. 'An invalid character string argument was used with the DECIMAL function.'

query used is
CAST(SUBSTR(ORE_RECORD_DATA,5,5) AS DEC(5))

Please, help me out.

Thanks
Bola

User avatar
DavidatK
Active Member
Posts: 65
Joined: Tue Mar 27, 2007 8:41 am
Location: Troy, MI USA

Cast function

Post by DavidatK » Wed Oct 24, 2007 9:27 pm

Bola,

I haven't had to do your requirement before, but I played around with it a little and this seems to work. There may be easier ways to accomplish the same thing. Maybe someone else will chime in with a different way.


HEX(SUBSTR(ORE_RECORD_DATE,5,5) = HEX(CAST(5000 AS DEC(9)))

Dave

bolastuff1975
Member
Posts: 8
Joined: Fri Sep 21, 2007 11:03 pm

CAST Function - done thanks

Post by bolastuff1975 » Fri Oct 26, 2007 5:06 pm

Hi Dave,

thanks very much for the reply. yes, it is working fine and also the below format is doing fine.

SUBSTR(ORE_RECORD_DATA,1390,5) = X'000005000C'

Thanks
Bola

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others