'DECFLOAT' error in db2

38.2k views Asked by At

Lookup Error - DB2 Database Error: ERROR [22018] [IBM][DB2/AIX64] SQL0420N Invalid character found in a character string argument of the function "DECFLOAT".

Query-----

SELECT 
   MSISDN,
   CONTRNO,
   TRANSDATE,
   TARIFF_GROUP,
   ACT_DURATION,
   BILLTEXT,
   GROSS_AMOUNT,
   CASE
       WHEN TARIFF_GROUP IN('PAG2')
       THEN DECIMAL((DECIMAL(ACT_DURATION,10,4)/10),20,4)*0.01
       ELSE 'CHECK'
   END RA_RATE
FROM HISTCALLS
WHERE call_type IN (50,
                    54)
  AND TRANSDATE = CURRENT date - 1 DAY

1

There are 1 answers

1
WarrenT On BEST ANSWER

The problem is in your case expression. A single result column cannot be numeric for some rows and character in others.

SELECT 
    MSISDN,
    CONTRNO,
    TRANSDATE,
    TARIFF_GROUP,
    ACT_DURATION,
    BILLTEXT,
    GROSS_AMOUNT,
    CASE
        WHEN TARIFF_GROUP = 'PAG2'
        THEN DECIMAL(ACT_DURATION * 0.001, 10,4)
        ELSE null
    END RA_RATE
  FROM HISTCALLS
  WHERE call_type IN (50, 54)
    AND TRANSDATE = CURRENT date - 1 DAY