In this section, you will find the how conditional and loop statements from oracle, are converted to JavaScript.
Some parts in the output code are omitted for clarity reasons.
IF, ELSIF and ELSE Statement
Oracle
IN -> Oracle_01.sql
--Additional Params: -t JavaScriptCREATE OR REPLACE PROCEDURE PROC1IS sal_raise NUMBER;BEGIN IF jobid ='PU_CLERK' THEN sal_raise := .09; ELSIF jobid ='SH_CLERK' THEN sal_raise := .08; ELSIF jobid ='ST_CLERK' THEN sal_raise := .07; ELSE sal_raise :=0; END IF;END;
Snowflake
OUT -> Oracle_01.sql
CREATE OR REPLACE PROCEDURE PROC1 ()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 SAL_RAISE;if ( !!!RESOLVE EWI!!! /*** SSC-EWI-0053 - OBJECT jobid MAY NOT WORK PROPERLY, ITS DATATYPE WAS NOT RECOGNIZED ***/!!! JOBID ==`PU_CLERK`) { SAL_RAISE =0.09; } elseif ( !!!RESOLVE EWI!!! /*** SSC-EWI-0053 - OBJECT jobid MAY NOT WORK PROPERLY, ITS DATATYPE WAS NOT RECOGNIZED ***/!!! JOBID ==`SH_CLERK`) { SAL_RAISE =0.08; } elseif ( !!!RESOLVE EWI!!! /*** SSC-EWI-0053 - OBJECT jobid MAY NOT WORK PROPERLY, ITS DATATYPE WAS NOT RECOGNIZED ***/!!! JOBID ==`ST_CLERK`) { SAL_RAISE =0.07; } else { SAL_RAISE =0; }$$;
Loop
Oracle
IN -> Oracle_02.sql
--Additional Params: -t JavaScriptCREATE OR REPLACE PROCEDURE PROC1 ISBEGIN<<outer_loop>> LOOP i := i +1; j :=0;<<inner_loop>> LOOP j := j +1; s := s + i * j; -- Sum several products END LOOP inner_loop; END LOOP outer_loop;END;
Snowflake
OUT -> Oracle_02.sql
CREATE OR REPLACE PROCEDURE PROC1 ()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.while ( true ) { I = !!!RESOLVE EWI!!! /*** SSC-EWI-0053 - OBJECT i MAY NOT WORK PROPERLY, ITS DATATYPE WAS NOT RECOGNIZED ***/!!! I +1; J =0;while ( true ) { J = !!!RESOLVE EWI!!! /*** SSC-EWI-0053 - OBJECT j MAY NOT WORK PROPERLY, ITS DATATYPE WAS NOT RECOGNIZED ***/!!! J +1; S = !!!RESOLVE EWI!!! /*** SSC-EWI-0053 - OBJECT s MAY NOT WORK PROPERLY, ITS DATATYPE WAS NOT RECOGNIZED ***/!!! S + !!!RESOLVE EWI!!! /*** SSC-EWI-0053 - OBJECT i MAY NOT WORK PROPERLY, ITS DATATYPE WAS NOT RECOGNIZED ***/!!! I * !!!RESOLVE EWI!!! /*** SSC-EWI-0053 - OBJECT j MAY NOT WORK PROPERLY, ITS DATATYPE WAS NOT RECOGNIZED ***/!!! J; } }$$;
While Statement
Oracle
IN -> Oracle_03.sql
--Additional Params: -t JavaScriptCREATE OR REPLACE PROCEDURE PROC1 ISI NUMBER :=1;J NUMBER :=10;BEGIN WHILE I <> J LOOP I := I+1; END LOOP;END;
Snowflake
OUT -> Oracle_03.sql
CREATE OR REPLACE PROCEDURE PROC1 ()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 I =1; let J =10;while ( I != J ) { I = I +1; }$$;