This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.
Severity
Low
Description
This warning is added when there is a query with a variable with a qualified member like an Oracle record or a Teradata for loop variable. Depending on where the variable is being used and the type of the value, a cast may be necessary to work properly.
Example Code
Input Code (Oracle):
CREATETABLETABLE1 (COL1 DATE);CREATETABLETABLE2 (COL1 VARCHAR(25));CREATEORREPLACEPROCEDURE EXAMPLEISCURSOR C1 ISSELECT*FROM TABLE1;BEGINFOR REC1 IN C1 LOOPinsert into TABLE2 values (TO_CHAR(REC1.COL1, 'DD-MM-YYYY'));ENDLOOP;END;
Output Code:
CREATE OR REPLACETABLEPUBLIC.TABLE1 ( COL1 DATE);CREATE OR REPLACETABLEPUBLIC.TABLE2 ( COL1 VARCHAR(25));CREATEORREPLACEPROCEDURE PUBLIC.EXAMPLE()RETURNS STRINGLANGUAGE JAVASCRIPTEXECUTEASCALLERAS$$// Additional helpers here let C1 = new CURSOR(`SELECT * FROM PUBLIC.TABLE1`,() => []); C1.OPEN();//** MSC-WARNING - MSCEWI1023 - PERFORMANCE REVIEW - THIS LOOP CONTAINS AN INSERT, DELETE OR UPDATE STATEMENT ** while ( C1.NEXT() ) { let REC1 = C1.CURRENT; EXEC(`insert into PUBLIC.TABLE2 values (TO_CHAR(/*** MSC-WARNING - MSCEWI1026 - THE VARIABLE REC1.COL1 MAY REQUIRE A CAST TO DATE, TIME OR TIMESTAMP ***/
?, 'DD-MM-YYYY'))`,[REC1.COL1]); } C1.CLOSE();$$;
Output Code with adjustments:
CREATE OR REPLACETABLEPUBLIC.TABLE1 ( COL1 DATE);CREATE OR REPLACETABLEPUBLIC.TABLE2 ( COL1 VARCHAR(25));CREATEORREPLACEPROCEDURE PUBLIC.EXAMPLE()RETURNS STRINGLANGUAGE JAVASCRIPTEXECUTEASCALLERAS$$// Additional helpers here let C1 = new CURSOR(`SELECT * FROM PUBLIC.TABLE1`,() => []); C1.OPEN();//** MSC-WARNING - MSCEWI1023 - PERFORMANCE REVIEW - THIS LOOP CONTAINS AN INSERT, DELETE OR UPDATE STATEMENT ** while ( C1.NEXT() ) { let REC1 = C1.CURRENT; EXEC(`insert into PUBLIC.TABLE2 values (TO_CHAR(?::DATE, 'DD-MM-YYYY'))`,[REC1.COL1]); } C1.CLOSE();$$;
Recommendations
Check if a cast to a Date, Time, or Timestamp is necessary for the binding. Some cases are not necessary because an implicit conversion is done to the value.