Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'DECFLOAT' error in db2

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

like image 360
Jabed Avatar asked Jul 01 '15 08:07

Jabed


1 Answers

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
like image 94
WarrenT Avatar answered Sep 17 '22 08:09

WarrenT