madsthiru madsthiru - 1 month ago 20
SQL Question

Teradata parser issue

I am trying to execute the below query but I get the error

INSERT INTO TABLEA(
CUSTOMER_CT_KEY,
CUSTOMER_ST_KEY,
CUSTOMER_TEST_KEY,
JAN_AMT,
FEB_AMT,
MAR_AMT)
SELECT
A.CUSTOMER_CT_KEY,
A.CUSTOMER_ST_KEY,
A.CUSTOMER_TEST_KEY,
SUM(CASE WHEN EXTRACT(MONTH FROM A.DATECOL) = '01'
THEN A.AAA_AMT
ELSE 0
END),
SUM(CASE WHEN EXTRACT(MONTH FROM A.DATECOL) = '02'
THEN A.BBB_AMT
ELSE 0
END),
SUM(CASE WHEN EXTRACT(MONTH FROM A.DATECOL) = '03'
THEN A.CCC_AMT
ELSE 0
END)
FROM TABLEB B, TABLEC C
WHERE B.DATECOL<= C.DATECOL
AND B.CUSTOMER_CT_KEY NOT IN
(SELECT FS_CUSTOMER_CT_KEY FROM TABLED WHERE REF_NBR = 'VALUE')
GROUP BY 1,2,3;

Insert failed. 3899: Internal Error in Teradata SQL parser


Output:

CUSTOMER_CT_KEY CUSTOMER_ST_KEY CUSTOMER_TEST_KEY JAN_AMT FEB_AMT MAR_AMT
123456789 541245812 541245812 114.00 524.00 62.00
658412457 632514257 632514257 0.00 12.00 214.00


Total number of rows in

TABLEA - EMPTY
TABLEB - 420,098,323
TABLEC - 1
TABLED - 218,074
INNER SUBQUERY - 5


When I tried hardcoding the value of the subquery it worked. Number of rows inserted : 105,615,541

Please guide me as how to proceed further. Thanks

Answer

Just an update on this issue. I have got the clarification from the Teradata Support. Before executing the Insert query, the following statement has to be executed.

diagnostic evlinterp on for session;
Comments