OUTPUT PARAMETERS
This article is about the current transformation of the output parameters and how their functionality is being emulated.
Description
An output parameter is a parameter whose value is passed out of the stored procedure/function module, back to the calling PL/SQL block. Since the output parameters are not supported by Snowflake Scripting, a solution has been implemented in order to emulate their functionality.
Sample Source Patterns
Single out parameter
Oracle
-- Procedure with output parameter declaration
CREATE OR REPLACE PROCEDURE proc_with_single_output_parameters(param1 OUT NUMBER)
IS
BEGIN
param1 := 123;
END;
-- Procedure with output parameter being called
CREATE OR REPLACE PROCEDURE proc_calling_proc_with_single_output_parameters
IS
var1 NUMBER;
BEGIN
proc_with_single_output_parameters(var1);
INSERT INTO TABLE01 VALUES(var1, -1);
END;Snowflake Scripting
Multiple out parameter
Oracle
Snowflake Scripting
In order to check that the functionality is being emulated correctly the following query is going to execute the procedure and a SELECT from the table mentioned before.
Oracle
Snowflake Scripting
Customer data type OUT parameters
When the output parameter is a customer type, the process is similar to a regular data type.
Oracle
Snowflake Scripting
Cursor OUT parameters
Cursor out parameters are not supported in Snowflake; despite that, a workaround that emulates Oracle's behavior is applied to the transformed code. The procedure with the out parameters generates a temporary table with a dynamic name, and the procedure call will define the name of the temp table as a string to create the table within the procedure call.
Oracle
Snowflake Scripting
Record OUT parameters
Records are not natively supported in Snowflake; however, a workaround was used to emulate them as output parameters. By defining an OBJECT variable instead of the record, we could emulate the record's field structure by assigning the out parameter result to each object property. Additionally, for each record field assigned as an out parameter, a new variable with the field type will be generated.
Oracle
Snowflake Scripting
Package Variables as OUT parameters
Packages are not supported in Snowflake, so their local members, like variables or constants, should also be preserved using a workaround. In this scenario, the package variable would be emulated using a session variable that would be updated after setting a local variable with the output parameter result.
Oracle
Snowflake Scripting
Known Issues
1. Procedures with output parameters inside packages may not work correctly
Currently, there is an issue collecting the semantic information of procedures that reside inside packages, which is why the transformation for output parameters may work partially or not work at all. There is already a work in progress to resolve this issue.
2. Some data types may not work properly
As seen in the transformation, when retrieving the value from the called procedures, an implicit cast is performed from VARIANT to the type specified by the variable. Since there are a lot of possible data types, some casts may fail or contain different data.
Related EWIs
SSC-FDM-0006: Number type column may not behave similarly in Snowflake.
SSC-FDM-0007: Element with missing dependencies.
SSC-FDM-0015: Data Type Not Recognized.
Last updated
