Convert Char string with Sign to Decimal in DB2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramanivx
    New Member
    • Aug 2015
    • 2

    Convert Char string with Sign to Decimal in DB2

    I need to convert a character string using DB2 SQL into a decimal (11,2). This character string has a sign also. I tried using Decimal verb and it gives ++++++++ sign after converting.
    Appreciate help.

    Example
    input:
    SUBSTR SUBSTR
    110006 0000000000{
    110011 0000000000{
    110016 0000000000{
    110020 0000000893H
    110071 0000000000{

    Query:
    select substr(varlenfl d, 18, 13),
    decimal(substr( varlenfld,229,1 1),11,2) from
    library/filename f

    output:
    SUBSTR DECIMAL
    110006 +++++++++++++++
    110011 +++++++++++++++
    110016 +++++++++++++++
    110020 +++++++++++++++
    110071 +++++++++++++++
    Last edited by ramanivx; Aug 25 '15, 08:51 PM. Reason: given example
  • ramanivx
    New Member
    • Aug 2015
    • 2

    #2
    I think it is possible to code but it is tedious to convert the last character into a hexa using a function in DB2. Can anyone help me come up with a hexa table for all the last characters. BTW, is there any better way in DB2 SQL?

    Comment

    Working...