Control Statements

In this section, you will find the how conditional and loop statements from oracle, are converted to JavaScript.

IF, ELSIF and ELSE Statement

Oracle

CREATE OR REPLACE PROCEDURE PROC1
IS
    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

SnowConvert helpers Code removed from the example. You can find them here.

CREATE OR REPLACE PROCEDURE PUBLIC.PROC1 ()
RETURNS STRING
LANGUAGE JAVASCRIPT
EXECUTE AS CALLER
AS
$$
   // REGION SnowConvert Helpers Code
   let SAL_RAISE;
   if (JOBID == `PU_CLERK`) {
      SAL_RAISE = 0.09000000357627869;
   } else if (JOBID == `SH_CLERK`) {
      SAL_RAISE = 0.07999999821186066;
   } else if (JOBID == `ST_CLERK`) {
      SAL_RAISE = 0.07000000029802322;
   } else {
      SAL_RAISE = 0;
   }
$$;

Loop

Oracle

Snowflake

SnowConvert helpers Code removed from the example. You can find them here.

While Statement

Oracle

Snowflake

SnowConvert helpers Code removed from the example. You can find them here.

Last updated

Was this helpful?