Procedure calls can be migrated to Snowflake as long as there are no optional parameters and their order matches the formal parameters. Please note that Procedure invocations get migrated to a Call statement.
Consider the next table and procedure for the examples below.
IN -> Oracle_01.sql
CREATE TABLE procedure_call_test_table( col1 INTEGER);-- Simple Called procedureCREATE OR REPLACE PROCEDURE called_procedure (param1 INTEGER)ASBEGIN INSERT INTO procedure_call_test_table VALUES (param1);END;
OUT -> Oracle_01.sql
CREATE OR REPLACE TABLE procedure_call_test_table ( col1 INTEGER ) COMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"oracle"}}' ;-- Simple Called procedureCREATE OR REPLACE PROCEDURE called_procedure (param1 INTEGER)RETURNS VARCHARLANGUAGE SQLCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$ BEGIN INSERT INTO procedure_call_test_tableVALUES (:param1); END;$$;
Simple call
Oracle
IN -> Oracle_02.sql
CREATE OR REPLACE PROCEDURE simple_calling_procedureASBEGIN called_procedure(1);END;CALL simple_calling_procedure();SELECT * FROM procedure_call_test_table;
COL1|
----+
1|
Snowflake Scripting
OUT -> Oracle_02.sql
CREATE OR REPLACE PROCEDURE simple_calling_procedure ()RETURNS VARCHARLANGUAGE SQLCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$ BEGIN CALL called_procedure(1); END;$$;CALL simple_calling_procedure();--** SSC-FDM-0007 - MISSING DEPENDENT OBJECT "procedure_call_test_table" **SELECT * FROM procedure_call_test_table;
COL1|
----+
1|
Calling a procedure with an optional parameter
This sample contains manual intervention for some functional differences and is used to explain them. For more information on these differences, please check the Known Issues section below.
Oracle
IN -> Oracle_03.sql
-- Procedure with optional parametersCREATE OR REPLACE PROCEDURE proc_optional_parameters (param1 INTEGER, param2 INTEGER :=8, param3 INTEGER)ASBEGIN INSERT INTO procedure_call_test_table VALUES (param1); INSERT INTO procedure_call_test_table VALUES (param2); INSERT INTO procedure_call_test_table VALUES (param3);END;CREATE OR REPLACE PROCEDURE calling_procedureASBEGIN-- positional convention proc_optional_parameters(1, 2, 3);-- named convention proc_optional_parameters(param1 =>4, param2 =>5, param3 =>6);-- named convention, second gets ommited proc_optional_parameters(param1 =>7, param3 =>9);-- named convention, different order proc_optional_parameters(param3 =>12, param1 =>10, param2 =>11);END;CALL calling_procedure();SELECT * FROM procedure_call_test_table;
-- Procedure with optional parametersCREATE OR REPLACE PROCEDURE proc_optional_parameters !!!RESOLVE EWI!!! /*** SSC-EWI-0002 - DEFAULT PARAMETERS MAY NEED TO BE REORDERED. SNOWFLAKE ONLY SUPPORTS DEFAULT PARAMETERS AT THE END OF THE PARAMETERS DECLARATIONS ***/!!! (param1 INTEGER, param2 INTEGER DEFAULT 8, param3 INTEGER)RETURNS VARCHARLANGUAGE SQLCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$ BEGIN INSERT INTO procedure_call_test_tableVALUES (:param1); INSERT INTO procedure_call_test_tableVALUES (:param2); INSERT INTO procedure_call_test_tableVALUES (:param3); END;$$;CREATE OR REPLACE PROCEDURE calling_procedure ()RETURNS VARCHARLANGUAGE SQLCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"oracle"}}'EXECUTE AS CALLERAS$$ BEGIN CALL-- positional convention proc_optional_parameters(1, 2, 3); CALL-- named convention proc_optional_parameters(param1 =>4, param2 =>5, param3 =>6); CALL-- named convention, second gets ommited proc_optional_parameters(param1 =>7, param3 =>9); CALL-- named convention, different order proc_optional_parameters(param1 =>10, param2 =>11, param3 =>12); END;$$;CALL calling_procedure();SELECT * FROM procedure_call_test_table;
1. Calling Subprograms with default values is not supported
Snowflake does not support setting default values for parameters. So these will need to be filled into every call.
2. Named parameters are accepted, but not functionally equivalent
These parameters will not cause any compilation errors when ran in Snowflake; however, calls still place them in a positional manner. For this reason, the order of these parameters needs to be checked. SnowConvert does not support checking nor reordering these parameters.
3. Calling Subprograms with Out Parameters is not supported
Snowflake does not have support for parameter modes, however, a solution is being implemented to emulate their functionality. To get more information about the transformation for output parameters please go to the following article Output Parameters.
Related EWIs
SSC-EWI-0002: Default Parameters May Need To Be Reordered.