Multiple Line If Body translation planned to be delivered in the future.
This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.
Severity
Medium
Description
Translation for if statements that contain a Begin ... End block inside their body is not supported yet for the entire statement block. Instead, this EWI and a Select Null are added.
CREATE OR REPLACEFUNCTIONPURCHASING.FOO (STATUSFLOAT)ReturnsINTLANGUAGESQLAS$$WITH CTE1 AS (SELECT10AS RESULT ), CTE2 AS (SELECT quantity AS RESULTFROM TESTS.TABLE1WHERE COL1 =STATUS ), CTE6 AS (SELECTCASEWHEN (SELECT RESULTFROM CTE2 ) =3THEN (SELECT /*** MSC-ERROR - MSCEWI4049 - TRANSLATION FOR MULTIPLE LINE IF BODY IS PLANNED TO BE DELIVERED IN THE FUTURE ***/
/*SELECT @result = 1*/nullFROM (SELECT /*** MSC-ERROR - MSCEWI4049 - TRANSLATION FOR MULTIPLE LINE IF BODY IS PLANNED TO BE DELIVERED IN THE FUTURE ***/
/*IF @result > 0 SELECT @result = 0 ELSE SELECT @result = 1*/null ) T1)ENDAS RESULT )SELECT RESULTFROM CTE6$$;
Manual Support
Case 1: Single Statement
For these cases, the transformation would be straightforward, since the transformed statement would appear in a select clause
IF @result =0BEGINSET @result =1END
CASEWHEN (SELECT RESULT FROM CTE2)=0THEN( SELECT1AS RESULT )
Case 2: Multiple Statements
For cases in which multiple statements are being transformed, we should transform the N Statement, and use it as the source table for the N+1 Statement.
IF @result =0BEGIN Statement1 Statement2 Statement3END
CASEWHEN (SELECT RESULT FROM CTE2)=0THEN(SELECT TransformedStatement3FROM (SELECT TransformedStatement2FROM (SELECT TransformedStatement1 ) T1 ) T2)
Case 3: Multiple set statements
For these cases, it will be necessary to replicate a transformation for each set statement.
IF @result =0BEGINSET @var1 =1SET @var2 =3SET @var3 = @var2END
WITH CTE1 AS (SELECTCASEWHEN (SELECT RESULTFROM CTE0) =0THEN (SELECT1) AS VAR1)WITH CTE2 AS (SELECTCASEWHEN (SELECT RESULTFROM CTE0)=0THEN (SELECT3) AS VAR2)WITH CTE3 AS (SELECTCASEWHEN (SELECT RESULTFROM CTE0)=0THEN (SELECT T1.VAR2 FROM ((SELECT3) AS VAR2) AS T1) AS VAR3) ...