SnowConvert helpers Code removed from the example. You can find them here.
OUT -> Oracle_01.sql
CREATE OR REPLACE PROCEDURE CONCAT_TEST ()RETURNS STRINGLANGUAGE JAVASCRIPTCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$// SnowConvert Helpers Code section is omitted. let NUM1 =123; let NUM2 =321; let VAR1 =`value`; let CONCAT_VAR; let SQL_STMT; CONCAT_VAR =`${concatValue(NUM1)}${concatValue(NUM2)}${concatValue(VAR1)}literal`; SQL_STMT =`INSERT INTO t1VALUES ('${concatValue(CONCAT_VAR)}')`; EXEC(SQL_STMT);$$;
Logical Operators
Oracle
IN -> Oracle_02.sql
--Additional Params: -t JavaScriptCREATE OR REPLACE PROCEDURE BOOLEAN_PROC (b_name VARCHAR2, b_value BOOLEAN)ISBOOL1 BOOLEAN := FALSE;x NUMBER :=5;y NUMBER :=NULL;BEGIN IF b_value IS NULL THENnull; ELSIF b_value = TRUE THENnull; ELSIF b_value = TRUE AND b_value = BOOL1 OR b_value = BOOL1 THENnull; ELSIF x > y THENnull; ELSIF x != y AND x <> y THENnull; ELSEnull; END IF;END;
--Additional Params: -t JavaScriptCREATE OR REPLACE PROCEDURE NULL_TESTISNUM1 INTEGER :=789;BEGIN IF NUM1 IS NOT NULL THENNULL; END IF; NUM1 :=NULL; IF NUM1 IS NULL THENNULL; END IF;END;
Snowflake
SnowConvert helpers Code removed from the example. You can find them here.
OUT -> Oracle_03.sql
CREATE OR REPLACE PROCEDURE NULL_TEST ()RETURNS STRINGLANGUAGE JAVASCRIPTCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$// SnowConvert Helpers Code section is omitted. let NUM1 =789;if (!IS_NULL(NUM1)) {null; } NUM1 = undefined;if (IS_NULL(NUM1)) {null; }$$;
When there is a LIKE operation, the helper function will be called instead.
Oracle
IN -> Oracle_04.sql
--Additional Params: -t JavaScriptCREATE OR REPLACE PROCEDURE PROCEDURE_WITH_LIKE ASBEGIN IF 'ABC' LIKE '%A%' THENnull; END IF; IF 'ABC' LIKE 'A%' THENnull; END IF; IF 'ABC' NOT LIKE 'D_%' THENnull; END IF; IF 'ABC' NOT LIKE 'D/%%' ESCAPE '/' THENnull; END IF;END;
Snowflake
SnowConvert helpers Code removed from the example. You can find them here.
OUT -> Oracle_04.sql
CREATE OR REPLACE PROCEDURE PROCEDURE_WITH_LIKE ()RETURNS STRINGLANGUAGE JAVASCRIPTCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$// SnowConvert Helpers Code section is omitted.if (LIKE(`ABC`,`%A%`)) {null; }if (LIKE(`ABC`,`A%`)) {null; }if (!LIKE(`ABC`,`D_%`)) {null; }if (!LIKE(`ABC`,`D/%%`,`/`)) {null; }$$;
--Additional Params: -t JavaScriptCREATE OR REPLACE PROCEDURE BETWEEN_TESTISNUM1 INTEGER :=789;US INTEGER :=1000;BEGIN IF 800 BETWEEN US AND NUM1 THENNULL; END IF; IF 'BA' BETWEEN 'B' AND 'CA' THENNULL; END IF;-- Assign null to the variable num1 NUM1 :=NULL; IF (0 BETWEEN NULL AND NUM1) IS NULL THENNULL; END IF;END;
Snowflake
SnowConvert helpers Code removed from the example. You can find them here.
OUT -> Oracle_05.sql
CREATE OR REPLACE PROCEDURE BETWEEN_TEST ()RETURNS STRINGLANGUAGE JAVASCRIPTCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$// SnowConvert Helpers Code section is omitted. let NUM1 =789; let US =1000;if (BetweenFunc(800,US,NUM1)) {null; }if (BetweenFunc(`BA`,`B`,`CA`)) {null; }// Assign nullto the variable num1 NUM1 = undefined;if (IS_NULL(BetweenFunc(0,undefined,NUM1))) {null; }$$;
IN Operator
Oracle
IN -> Oracle_06.sql
--Additional Params: -t JavaScriptCREATE OR REPLACE PROCEDURE IN_PROCISletter VARCHAR2(1) :='m';BEGIN IF letter IN ('a', 'b', 'c') THENnull; ELSEnull; END IF;END;
Snowflake
SnowConvert helpers Code removed from the example. You can find them here.
OUT -> Oracle_06.sql
CREATE OR REPLACE PROCEDURE IN_PROC ()RETURNS STRINGLANGUAGE JAVASCRIPTCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$// SnowConvert Helpers Code section is omitted. let LETTER =`m`;if ([`a`,`b`,`c`].includes(LETTER)) {null; } else {null; }$$;
Boolean Expressions
Oracle
IN -> Oracle_07.sql
--Additional Params: -t JavaScriptCREATE OR REPLACE PROCEDURE BOOLEAN_TESTISdone BOOLEAN;BEGIN-- These WHILE loops are equivalent done := FALSE; WHILE done = FALSE LOOP done := TRUE; END LOOP; done := FALSE; WHILE NOT (done = TRUE) LOOP done := TRUE; END LOOP; done := FALSE; WHILE NOT done LOOP done := TRUE; END LOOP;END;
Snowflake
SnowConvert helpers Code removed from the example. You can find them here.
OUT -> Oracle_07.sql
CREATE OR REPLACE PROCEDURE BOOLEAN_TEST ()RETURNS STRINGLANGUAGE JAVASCRIPTCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$// SnowConvert Helpers Code section is omitted. let DONE;// These WHILE loops are equivalent DONE = false;while ( DONE == false ) { DONE = true; } DONE = false;while ( !(DONE == true) ) { DONE = true; } DONE = false;while ( !DONE ) { DONE = true; }$$;
Function Expressions
For Function Expressions inside procedures, they are being converted to the corresponding function or expression in Snowflake. These function calls are passed to an EXEC with a CALL or a SELECT depending on the converted value.