Probleme with Case When syntax

Teradata Studio
Ju
Fan

Probleme with Case When syntax

Hi, 

 

I write this syntax for a case when , but i have the next error message : 

Syntax error, expected something like an 'END' keyword between the word 'L32_CTRA_DEBT_RSTRU_DT' and '='.

CASE WHEN STG_CTRA_DEBT_RSTRU_IN.CTRA_DEBT_RSTRU_IN <> DWH_DEFLT_GIVEN_LOSS_SRC.CTRA_DEBT_RSTRU_IN
     THEN STG_CTRA_DEBT_RSTU_DT.CTRA_DEBT_RSTRU_DT = DWH_CTRA.CTRA_ADM_STTS_DT
     ELSE STG_CTRA_DEBT_RSTU_DT.CTRA_DEBT_RSTRU_DT = DWH_DEFLT_GIVEN_LOSS_SRC.CTRA_DEBT_RSTRU_DT 
END
1 REPLY 1
Teradata Employee

Re: Probleme with Case When syntax

CASE is an expression, not a conditional statement; so you can't do assignment within the WHEN/THEN. Perhaps you are looking for something like this?

UPDATE ...
SET STG_CTRA_DEBT_RSTU_DT.CTRA_DEBT_RSTRU_DT = CASE WHEN STG_CTRA_DEBT_RSTRU_IN.CTRA_DEBT_RSTRU_IN <> DWH_DEFLT_GIVEN_LOSS_SRC.CTRA_DEBT_RSTRU_IN THEN DWH_CTRA.CTRA_ADM_STTS_DT ELSE DWH_DEFLT_GIVEN_LOSS_SRC.CTRA_DEBT_RSTRU_DT END

Or if this is INSERT SELECT then the target column determination is part of the INSERT and the CASE expression just needs to provide the value.