PROCEDURE CALL Translation reference for PROCEDURE CALL aka SUBPROGRAM INVOCATION
Some parts in the output code are omitted for clarity reasons.
Description
This section describes the syntax for subprogram invocations within PL blocks, such as procedures or anonymous blocks.
For more information on this subject, please refer to Oracle's Subprogram documentation: (Oracle PL/SQL Language Reference Subprogram Invocation Statement )
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.
Oracle Subprogram Invocation Syntax
Copy < subprogram invocation > : = subprogram_name [ ( [ parameter [, parameter]... ] ) ]
< parameter > : = {
< actual parameter >
| < formal parameter name> => < actual parameter >
}
Snowflake Scripting has support for this statement, albeit with some functional differences.
Snow Scripting Subprogram Invocation Syntax
Copy < subprogram invocation > : = CALL subprogram_name [ ( [ parameter [, parameter]... ] ) ]
< parameter > : = {
< actual parameter >
| < formal parameter name> => < actual parameter >
}
Sample Source Patterns
Consider the next table and procedure for the examples below.
Oracle Snowflake
Copy CREATE TABLE procedure_call_test_table (
col1 INTEGER
);
-- Simple Called procedure
CREATE OR REPLACE PROCEDURE called_procedure (param1 INTEGER )
AS
BEGIN
INSERT INTO procedure_call_test_table VALUES (param1);
END ;
Copy 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 procedure
CREATE OR REPLACE PROCEDURE called_procedure (param1 INTEGER )
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"oracle"}}'
EXECUTE AS CALLER
AS
$$
BEGIN
INSERT INTO procedure_call_test_table
VALUES (:param1);
END ;
$$;
Simple call
Oracle
Query Result
Copy CREATE OR REPLACE PROCEDURE simple_calling_procedure
AS
BEGIN
called_procedure( 1 );
END ;
CALL simple_calling_procedure();
SELECT * FROM procedure_call_test_table;
Snowflake Scripting
Query Result
Copy CREATE OR REPLACE PROCEDURE simple_calling_procedure ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'
EXECUTE AS CALLER
AS
$$
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;
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
Query Result
Copy -- Procedure with optional parameters
CREATE OR REPLACE PROCEDURE proc_optional_parameters (param1 INTEGER , param2 INTEGER : = 8 , param3 INTEGER )
AS
BEGIN
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_procedure
AS
BEGIN