how to set a value from case statement in Teradata store procedure

Database
Enthusiast

how to set a value from case statement in Teradata store procedure

Hi I am learning Teradata storeproc. Please help me with the solution for the below

store proc:

CREATE  PROCEDURE CASE_PROC

(IN VAR1 BYTEINT, IN VAR2 BYTEINT, OUT MSG CHAR(20))

BEGIN

SET MSG= CASE WHEN VAR1=VAR2 THEN 'THEY ARE EQUAL'

CASE WHEN VAR1<VAR2 THEN 'VARIABLE 1 LESS'

ELSE 'VARIABLE 1 GREATER'

END CASE;

END CASE;

END;

Syntax Error:

SPL1027:E(L10), Missing/Invalid SQL statement'E(3707):Syntax error, expected something like an 'END' keyword between a string or a Unicode character literal and the 'CASE' keyword.'.

SPL1027:E(L11), Missing/Invalid SQL statement'E(3707):Syntax error, expected something like ';' between the 'END' keyword and the 'CASE' keyword.'.

1 REPLY
Junior Contributor

Re: how to set a value from case statement in Teradata store procedure

There's no "END CASE", it's just END.

Dieter