SnowConvert AI - Oracle - PL/SQL to Snowflake Scripting¶
ASSIGNMENT STATEMENT¶
Description¶
The assignment statement sets the value of a data item to a valid value.
(Oracle PL/SQL Language Reference ASSIGNMENT Statement)
Note
Some parts in the output code are omitted for clarity reasons.
Oracle Assignment Syntax¶
Snowflake Scripting Assignment Syntax¶
Note
LET keyword is not needed for assignment statements when the variable has been declared before. Check Snowflake Assignment documentation for more information.
Sample Source Patterns¶
1. Scalar Variables¶
Oracle¶
Result¶
COL1 |
COL2 |
COL3 |
COL4 |
|---|---|---|---|
1 |
4.2 |
Hello World |
1 |
Snowflake Scripting¶
Result¶
COL1 |
COL2 |
COL3 |
COL4 |
|---|---|---|---|
1.000000000000000000 |
4.000000000000000000 |
Hello World |
1 |
Warning
Transformation for some data types needs to be updated, it may cause different results. For example, NUMBER to NUMBER rounds the value and the decimal point is lost. There is already a work item for this issue.
2. Out Parameter Assignment¶
To get more information about how the output parameters are being converted, please go to the following article Output Parameters.
3. Not Supported Assignments¶
Oracle¶
Snowflake Scripting¶
Known Issues¶
1. Several Unsupported Assignment Statements¶
Currently, transformation for cursor, collection, record, and user-defined type variables are not supported by Snow Scripting. Therefore assignment statements using these variables are commented and marked as not supported. Changing these variables to Snowflake semi-structured data types could help as a workaround in some scenarios.
CALL¶
Description¶
There are two types of call statements in Oracle:
1-CALL Statement:¶
Use the
CALLstatement to execute a routine (a standalone procedure or function, or a procedure or function defined within a type or package) from within SQL. (Oracle SQL Language Reference CALL)
2-Call Specification:¶
A call specification declares a Java method or a C language subprogram so that it can be invoked from PL/SQL. (Oracle SQL Language Reference Call Specification)
The CALL Specification is not supported in Snowflake Scripting since this is part of the development libraries for C and JAVA, not a SQL statement, therefore this statement is not transformed.
Known Issues¶
No issues were found.
Related EWIs¶
No related EWIs.
CASE¶
Translation reference for CASE statements
Description¶
The
CASEstatement chooses from a sequence of conditions and runs a corresponding statement. For more information regarding Oracle CASE, check here.
Note
Some parts in the output code are omitted for clarity reasons.
Simple case¶
Oracle CASE Syntax¶
Snowflake Scripting CASE Syntax¶
Searched case¶
Oracle CASE Syntax¶
Snowflake Scripting CASE Syntax¶
Sample Source Patterns¶
Sample auxiliary table¶
Oracle¶
Snowflake¶
Simple Case¶
Oracle¶
Result¶
COL |
|---|
Poor |
No such grade |
Excellent |
Snowflake Scripting¶
Result¶
COL |
|---|
Poor |
No such grade |
Excellent |
Searched Case¶
Oracle¶
Result¶
COL |
|---|
Poor |
No such grade |
Excellent |
Snowflake Scripting¶
Result¶
COL |
|---|
Poor |
No such grade |
Excellent |
Known issues¶
1. Labels are not supported in Snowflake Scripting CASE syntax¶
The labels are commented out or removed depending on their position.
Related EWIs¶
SSC-EWI-0094: Label declaration not supported.
SSC-FDM-0007: Element with missing dependencies.
COMPOUND STATEMENTS¶
This section is a translation specification for the compound statements
Warning
This section is a work in progress, information may change in the future.
Note
Some parts in the output code are omitted for clarity reasons.
General description¶
The basic unit of a PL/SQL source program is the block, which groups related declarations and statements.
A PL/SQL block is defined by the keywords DECLARE, BEGIN, EXCEPTION, and END. These keywords divide the block into a declarative part, an executable part, and an exception-handling part. Only the executable part is required. (PL/SQL Anonymous Blocks)
The BEGIN...END block in Oracle can have the following characteristics:
Be nested.
Contain the DECLARE statement for variables.
Group multiple SQL or PL/SQL statements.
Oracle syntax¶
Snowflake syntax¶
Note
In Snowflake, a BEGIN/END block can be the top-level construct inside an anonymous block (Snowflake documentation).
Sample Source Patterns¶
1. IF-ELSE block¶
Review the following documentation about IF statements to learn more: SnowConvert AI IF statements translation and Snowflake IF statement documentation
Oracle¶
Result¶
Snowflake¶
Warning
When calling a procedure or user-defined function (UDF), generating code is needed to support the equivalence as call_results variable. In this case, is used to print the information.
Review the user-defined function (UDF) used here.
Result¶
2. CASE statement¶
For more information, review the following documentation: SnowConvert AI CASE statement documentation and Snowflake CASE documentation
Oracle¶
Result¶
Snowflake¶
Warning
When calling a procedure or user-defined function (UDF), generating code is needed to support the equivalence as call_results variable. In this case, is used to print the information.
Review the user-defined function (UDF) used here.
Result¶
3. LOOP statements¶
For more information review the following documentation: SnowConvert AI FOR LOOP and Snowflake LOOP documentation and FOR documentation.
Oracle¶
Result¶
Snowflake¶
First Tab¶
Result¶
4. Procedure call and OUTPUT parameters¶
Anonymous block in Oracle may have calls to procedures. Furthermore, the following documentation may be useful: SnowConvert AI Procedure documentation.
The following example uses the OUT parameters, the information about the current transformation can be found here: SnowConvert AI OUTPUT Parameters
Oracle¶
Result¶
Snowflake¶
Result¶
5. Alter session¶
For more information, review the following documentation: Alter session documentation.
Notice that in Oracle, the block BEGIN...END should use the EXECUTE IMMEDIATE statement to run alter session statements.
Oracle¶
Result¶
Snowflake¶
Result¶
6. Cursors¶
The following example displays the usage of a cursor inside a BEGIN...END block. Review the following documentation to learn more: Cursor documentation.
Oracle¶
Result¶
Snowflake¶
Warning
When calling a procedure or user-defined function (UDF), generating code is needed to support the equivalence as call_results variable. In this case, is used to print the information.
Review the user-defined function (UDF) used here.
Result¶
7. Select statements¶
For more information review the following documentation: Select documentation.
Oracle¶
Result¶
Snowflake¶
Warning
When calling a procedure or user-defined function (UDF), generating code is needed to support the equivalence as call_results variable. In this case, is used to print the information.
Review the user-defined function (UDF) used here.
Result¶
8. Join Statements¶
For more information review the following documentation: Joins documentation.
Oracle¶
Result¶
Snowflake¶
Warning
When calling a procedure or user-defined function (UDF), generating code is needed to support the equivalence as call_results variable. In this case, is used to print the information.
Review the user-defined function (UDF) used here.
9. Exception handling¶
Oracle¶
Result¶
Snowflake¶
Warning
ZERO_DIVIDE exception in Snowflake is not supported.
Result¶
Known issues¶
Unsupported GOTO statements in Oracle.
Exceptions that use GOTO statements may be affected too.
Cursor functionality may be adapted under current restrictions on translations.
Related EWIs¶
SSC-EWI-0027:The following statement uses a variable/literal with an invalid query and it will not be executed.
SSC-EWI-OR0036: Types resolution issues, the arithmetic operation may not behave correctly between string and date.
SSC-FDM-OR0035: DBMS_OUTPUT.PUTLINE check UDF implementation.
SSC-FDM-0006: Number type column may not behave similarly in Snowflake.
SSC-PRF-0004: This statement has usages of cursor for loop.
SSC-EWI-0030: The statement below has usages of dynamic SQL
CONTINUE¶
Translation reference to convert Oracle CONTINUE statement to Snowflake Scripting
Description¶
The
CONTINUEstatement exits the current iteration of a loop, either conditionally or unconditionally, and transfers control to the next iteration of either the current loop or an enclosing labeled loop.
(Oracle PL/SQL Language Reference CONTINUE Statement)
Note
Some parts in the output code are omitted for clarity reasons.
Oracle CONTINUE Syntax¶
Snowflake Scripting CONTINUE Syntax¶
Sample Source Patterns¶
1. Simple Continue¶
Code skips the INSERT statement by using CONTINUE.
Note
This case is functionally equivalent.
Oracle¶
Result¶
ITERATOR |
|---|
Snowflake Scripting¶
Result¶
ITERATOR |
|---|
2. Continue with condition¶
Code skips inserting even numbers by using CONTINUE.
Note
This case is not functionally equivalent, but, you can turn the condition into an IF statement.
Oracle¶
Result¶
ITERATOR |
|---|
1 |
3 |
5 |
7 |
9 |
11 |
13 |
15 |
17 |
19 |
21 |
Snowflake Scripting¶
Result¶
ITERATOR |
|---|
1 |
3 |
5 |
7 |
9 |
11 |
13 |
15 |
17 |
19 |
21 |
3. Continue with label and condition¶
Code skips line 19, and the inner loop is only executed once because the CONTINUE is always jumping to the outer loop using the label.
Note
This case is functionally equivalent applying the same process as the previous sample.
Note
Note that labels are going to be commented out.
Oracle¶
Result¶
ITERATOR |
|---|
I1 |
K1 |
K2 |
K3 |
K4 |
K5 |
I2 |
I3 |
I4 |
I5 |
I6 |
I7 |
I8 |
I9 |
I10 |
I11 |
Snowflake Scripting¶
Result¶
ITERATOR |
|---|
I1 |
K1 |
K2 |
K3 |
K4 |
K5 |
I2 |
I3 |
I4 |
I5 |
I6 |
I7 |
I8 |
I9 |
I10 |
I11 |
Known Issues¶
No issues were found.
Related EWIs¶
SSC-EWI-0094: Label declaration not supported.
DECLARE¶
Translation reference to convert Oracle DECLARE statement to Snowflake Scripting
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
Oracle DECLARE statement is an optional part of the PL/SQL block statement. It allows the creation of variables, constants, procedures declarations, and definitions, functions declarations, and definitions, exceptions, cursors, types, and many other statements. For more information regarding Oracle DECLARE, check here.
Oracle DECLARE Syntax¶
Snowflake Scripting DECLARE Syntax¶
Sample Source Patterns¶
Variable declaration¶
Oracle Variable Declaration Syntax¶
Snowflake Scripting Variable Declaration Syntax¶
Oracle¶
Snowflake Scripting¶
Constant declaration¶
Warning
Constants are not supported in Snowflake Scripting, however, they are being transformed to variables to simulate the behavior.
Oracle Constant Declaration Syntax¶
Snowflake Scripting Variable Declaration Syntax¶
Oracle¶
Snowflake Scripting¶
Cursor declaration¶
Oracle Cursor Declaration Syntax¶
Snowflake Scripting Cursor Declaration Syntax¶
Danger
The Oracle cursor declaration is not required so it might be commented out on the output code. The cursor definition will be used instead of and it will be converted to the Snowflake Scripting cursor declaration. Please go to the CURSOR section to get more information about cursor definition.
Exception declaration¶
The exception declaration sometimes could be followed by the exception initialization, the current transformation takes both and merge them into the Snowflake Scripting exception declaration. The original PRAGMA EXCEPTION_INIT will be commented out.
Oracle Exception Declaration Syntax¶
Snowflake Scripting Exception Declaration Syntax¶
Oracle¶
Snowflake Scripting¶
Not supported cases¶
The next Oracle declaration statements are not supported by the Snowflake Scripting declaration block:
Cursor variable declaration.
Collection variable declaration.
Record variable declaration.
Type definition (all its variants).
Function declaration and definition.
Procedure declaration and definition.
Known issues¶
1. The variable declarations with NOT NULL constraints are not supported by Snow Scripting.¶
The creation of variables with NOT NULL constraint throws an error in Snow Scripting.
2. The cursor declaration has no equivalent to Snowflake Scripting.¶
The Oracle cursor declaration is useless so it might be commented out in the output code. The cursor definition will be used instead and it will be converted to the Snowflake Scripting cursor declaration.
3. The exception code exceeds Snowflake Scripting limits.¶
Oracle exception code is being removed when it exceeds the Snowflake Scripting code limits. The exception code must be an integer between -20000 and -20999.
3. The not supported cases.¶
There are some Oracle declaration statements that are not supported by the Snowflake Scripting declaration block, so it might be commented out and a warning will be added.
Related EWIs¶
SSC-EWI-OR0051: PRAGMA EXCEPTION_INIT is not supported.
SSC-EWI-OR0099: The exception code exceeds the Snowflake Scripting limit.
SSC-FDM-0016: Constants are not supported by Snowflake Scripting. It was transformed into a variable.
SSC-FDM-OR0025: Not Null constraint is not supported in Snowflake Procedures.
DEFAULT PARAMETERS¶
This article is about the current transformation of the default parameters and how their functionality is being emulated.
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
A default parameter is a parameter that has a value in case an argument is not passed in the procedure or function call. Since Snowflake doesn’t support default parameters, SnowConvert AI inserts the default value in the procedure or function call.
In the declaration, the DEFAULT VALUE clause of the parameter is removed. Both syntaxes, the := symbol and the DEFAULT clause, are supported.
Sample Source Patterns¶
Sample auxiliaryy code¶
Oracle¶
Snowflake¶
Default parameter declaration¶
Oracle¶
Snowflake Scripting¶
Calling procedures with default parameters¶
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¶
Result¶
COL1 |
COL2 |
|---|---|
10 |
15 |
10 |
1 |
10 |
15 |
10 |
2 |
1 |
2 |
Snowflake Scripting¶
Result¶
COL1 |
COL2 |
|---|---|
10 |
15 |
10 |
1 |
10 |
15 |
10 |
2 |
1 |
2 |
Calling procedures with named arguments and default parameters¶
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¶
Result¶
COL1 |
COL2 |
COL3 |
|---|---|---|
10 |
20 |
30 |
10 |
20 |
30 |
20 |
30 |
10 |
100 |
30 |
10 |
100 |
10 |
30 |
100 |
10 |
1000 |
Snowflake Scripting¶
Result¶
COL1 |
COL2 |
COL3 |
|---|---|---|
10 |
20 |
30 |
10 |
20 |
30 |
20 |
30 |
10 |
100 |
30 |
10 |
100 |
10 |
30 |
100 |
10 |
1000 |
Known Issues¶
1. No issues found
Related EWIs¶
No related EWIs.
EXECUTE IMMEDIATE¶
Translation reference to convert Oracle EXECUTE IMMEDIATE statement to Snowflake Scripting
Description¶
The
EXECUTEIMMEDIATEstatement builds and runs a dynamic SQL statement in a single operation.Native dynamic SQL uses the
EXECUTEIMMEDIATEstatement to process most dynamic SQL statements. (Oracle PL/SQL Language Reference EXECUTE IMMEDIATE Statement)
Oracle EXECUTE IMMEDIATE Syntax¶
Snowflake Scripting has support for this statement, albeit with some functional differences. For more information on the Snowflake counterpart, please visit Snowflake’s EXECUTE IMMEDIATE documentation.
Snow Scripting EXECUTE IMMEDIATE Syntax¶
Sample Source Patterns¶
The next samples will create a table, and attempt to drop the table using Execute Immediate.
Using a hard-coded string¶
Oracle¶
Snowflake Scripting¶
Storing the string in a variable¶
Oracle¶
Snowflake Scripting¶
Concatenation for parameters in dynamic statement¶
Oracle¶
Snowflake Scripting¶
USING Clause transformation¶
Oracle¶
Results¶
COL1 |
|---|
1 |
Snowflake Scripting¶
Note
Please note parenthesis are required for parameters in the USING Clause in Snowflake Scripting.
Results¶
COL1 |
|---|
1 |
Known Issues¶
1. Immediate Execution results cannot be stored in variables.¶
SnowScripting does not support INTO nor BULK COLLECT INTO clauses. For this reason, results will need to be passed through other means.
2. Numeric Placeholders¶
Numeric Names for placeholders are currently not being recognized by SnowConvert AI, but there is a work item to fix this issue.
3. Argument Expressions are not supported by Snowflake Scripting¶
In Oracle it is possible to use Expressions as Arguments for the Using Clause; however, this is not supported by Snowflake Scripting, and they are commented out.
4. Dynamic SQL Execution queries may be marked incorrectly as non-runnable.¶
In some scenarios there an execute statement may be commented regardless of being safe or non-safe to run so please take this into account:
Oracle¶
Snowflake Scripting¶
Note
Please note parenthesis are required for parameters in the USING Clause in Snowflake Scripting.
Related EWIs¶
SSC-EWI-0027: Variable with invalid query.
SSC-EWI-0030: The statement below has usages of dynamic SQL.
EXIT¶
Translation reference to convert Oracle EXIT statement to Snowflake Scripting
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
The
EXITstatement exits the current iteration of a loop, either conditionally or unconditionally, and transfers control to the end of either the current loop or an enclosing labeled loop.
(Oracle PL/SQL Language Reference EXIT Statement)
Oracle EXIT Syntax¶
Snowflake Scripting EXIT Syntax¶
Sample Source Patterns¶
Note
Note that you can change EXITwith BREAKand everything will work the same.
1. Simple Exit¶
Code skips the INSERT statement by using EXIT.
Note
This case is functionally equivalent.
Oracle¶
Result¶
ITERATOR |
|---|
Snowflake Scripting¶
Result¶
ITERATOR |
|---|
2. Exit with condition¶
Code exits the loop when the iterator is greater than 5.
Note
This case is functionally equivalent by turning the condition into an IF statement.
Oracle¶
Result¶
ITERATOR |
|---|
1 |
2 |
3 |
4 |
5 |
6 |
Snowflake Scripting¶
Result¶
ITERATOR |
|---|
1 |
2 |
3 |
4 |
5 |
6 |
3. Exit with label and condition¶
Code breaks both loops by using the EXIT statement pointing to the outer loop.
Note
This case is functionally equivalent applying the same process as the previous sample.
Note
Note that labels are going to be commented out.
Oracle¶
Result¶
ITERATOR |
|---|
I1 |
K1 |
K2 |
K3 |
K4 |
K5 |
Snowflake Scripting¶
Result¶
ITERATOR |
|---|
I1 |
K1 |
K2 |
K3 |
K4 |
K5 |
Known Issues¶
No issues were found.
Related EWIs¶
SSC-EWI-0094: Label declaration not supported.
EXPRESSIONS¶
Translation reference for Oracle expressions to Snow Scripting
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
The following table has a summary of how to transform the different Oracle Expression kinds into Snow Scripting.
Syntax |
Conversion status |
Notes |
|---|---|---|
Partial |
||
Partial |
||
Partial |
||
Partial |
||
Full |
N/A |
|
Full |
N/A |
|
Not Translated |
Snowflake does not have a native equivalent for Oracle collections. See Collections and Records. |
|
Not Translated |
Snowflake does not have a native equivalent for Oracle record types. See Collections and Records. |
Partially supported common scenarios¶
Oracle Constants¶
Oracle¶
Result¶
COL |
|---|
CONSTANT TEXT |
Snowflake¶
Result¶
COL |
|---|
CONSTANT TEXT |
Not supported numeric expressions¶
Oracle¶
Result¶
COL |
|---|
4 |
104 |
11 |
3 |
Not supported boolean expressions¶
Oracle¶
Related EWIs.¶
SSC-FDM-0016: Constants are not supported by Snowflake Scripting. It was transformed to a variable.
FOR LOOP¶
Description¶
With each iteration of the
FORLOOPstatement, its statements run, its index is either incremented or decremented, and control returns to the top of the loop. (Oracle PL/SQL Language Reference FOR LOOP Statement).
Oracle Syntax¶
Snowflake Scripting Syntax¶
Snowflake Scripting supports FOR LOOP that loops a specified number of times. The upper and lower bounds must be INTEGER. Check more information in the Snowflake Scripting documentation.
Oracle FOR LOOP behavior can also be modified by using the statements:
Sample Source Patterns¶
1. FOR LOOP¶
Note
This case is functionally equivalent.
Oracle FOR LOOP Example¶
Snowflake Scripting FOR LOOP Example¶
2. FOR LOOP with additional clauses¶
Oracle FOR LOOP Example¶
Snowflake Scripting FOR LOOP Example¶
3. FOR LOOP with multiple conditions¶
Oracle FOR LOOP Example¶
Snowflake Scripting FOR LOOP Example¶
4. FOR LOOP with unsupported format¶
Oracle FOR LOOP Example¶
Snowflake Scripting FOR LOOP Example¶
Warning
Transformation for custom types is currently not supported for Snowflake Scripting.
Known Issues¶
1. For With Multiple Conditions¶
Oracle allows multiple conditions in a single FOR LOOP however, Snowflake Scripting only allows one condition per FOR LOOP. Only the first condition is migrated and the others are ignored during transformation. Check SSC-FDM-OR0022.
Oracle¶
Snowflake Scripting FOR LOOP Example¶
2. Mutable vs Inmutable Counter Variable
Oracle allows modifying the value of the FOR LOOP variable inside the loop. The current documentation includes this functionality but Snowflake recommends avoiding this. Modifying the value of this variable may not behave correctly in Snowflake Scripting.
3. Integer vs Float number for Upper or Lower Bound
Snowflake Scripting only allows an INTEGER or an expression that evaluates to an INTEGER as a bound for the FOR LOOP condition. Floating numbers will be rounded up or down and alter the original bound.
4. Oracle Unsupported Clauses
Oracle allows additional clauses to the FOR LOOP condition. Like the BY clause for a stepped increment in the condition. And the WHILE and WHEN clause for boolean expressions. These additional clauses are not supported in Snowflake Scripting and are ignored during transformation. Check SSC-EWI-OR0101.
Oracle¶
Snowflake Scripting¶
5. Unsupported Formats
Oracle allows different types of conditions for a FOR LOOP. It supports boolean expressions, collections, records… However, Snowflake scripting only supports FOR LOOP with defined integers as bounds. All other formats are marked as not supported and require additional manual effort to be transformed. Check SSC-EWI-OR0103.
Related EWIs¶
SSC-EWI-0058: Functionality is not currently supported by Snowflake Scripting.
SSC-EWI-0062: Custom type usage changed to variant.
SSC-EWI-OR0100: For Loop With Multiple Conditions Is Currently Not Supported By Snowflake Scripting. Only First Condition Is Used.
SSC-EWI-OR0101: Specific For Loop Clause Is Currently Not Supported By Snowflake Scripting.
SSC-EWI-OR0103: For Loop Format Is Currently Not Supported By Snowflake Scripting.
FORALL¶
Description¶
The
FORALLstatement runs one DML statement multiple times, with different values in theVALUESandWHEREclauses. (Oracle PL/SQL Language Reference FORALL Statement).
Oracle Syntax¶
Warning
Snowflake Scripting has no direct equivalence with the FORALL statement, however can be emulated with different workarounds to get functional equivalence.
Sample Source Patterns¶
Setup Data¶
Oracle¶
Tables 1¶
Tables 2¶
Snowflake¶
Tables 1¶
Tables 2¶
1. FORALL With Collection of Records¶
Oracle¶
Note
The three cases below have the same transformation to Snowflake Scripting and are functionally equivalent.
Source¶
Results¶
COLUMN1 |
COLUMN2 |
|---|
Snowflake¶
FORALL With Collection of Records¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
Note
The EWIs SSC-PRF-0001 and SSC-PRF-0003 are added in every FETCH BULK COLLECT occurrence into FORALL statement.
2. FORALL With INSERT INTO¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
3. FORALL With Multiple Fetched Collections¶
Oracle¶
With INSERT INTO¶
With UPDATE¶
Results INSERT INTO¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
1 |
2 |
Results UPDATE¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2. |
Snowflake¶
With INSERT INTO¶
With UPDATE¶
Results INSERT INTO¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
Results UPDATE¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
4. FORALL With Record of Collections¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
Scripting FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
5. FORALL With Dynamic SQL¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
6. FORALL With Literal SQL¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
7. FORALL With Parametrized Cursors¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
8. FORALL Without LOOPS¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
9. FORALL With UPDATE Statements¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
54321 |
2 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
54321 |
2 |
10. FORALL With DELETE Statements¶
Oracle¶
FORALL Example¶
Results¶
Snowflake¶
FORALL Equivalent¶
Results¶
11. FORALL With PACKAGE References¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
10 |
10 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
10.000000000000000000 |
10.000000000000000000 |
Warning
The transformation above only works if the variable defined in the package is a record of collections.
12. FORALL With MERGE Statements¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
4 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
1.000000000000000000 |
4.000000000000000000 |
Warning
The transformation above only works if the SELECT statement inside the MERGE is selecting from DUAL table.
13. Default FORALL transformation¶
Note
You might also be interested in Bulk Cursor Helpers.
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
Note
This transformation is done only when none of the previously mentioned transformations can be done.
14. Multiple FORALL inside a LOOP clause¶
Note
This pattern applies when there is more than one FORALL in the same procedure and it meets the following structure.
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
54321 |
2 |
54321 |
2 |
54321 |
3 |
54321 |
4 |
54321 |
5 |
54321 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
54321 |
2 |
54321 |
2 |
54321 |
3 |
54321 |
4 |
54321 |
5 |
54321 |
6 |
15. Multiple FORALL inside different LOOP clauses¶
Note
This pattern applies when there is more than one FORALL in the same procedure and it meets the following structure.
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
54321 |
2 |
54321 |
2 |
54321 |
3 |
54321 |
4 |
54321 |
5 |
54321 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
54321 |
2 |
54321 |
2 |
54321 |
3 |
54321 |
4 |
54321 |
5 |
54321 |
6 |
16. FORALL with MERGE INTO with LOG ERRORS¶
Warning
This pattern is not yet implemmented
Oracle¶
LOG ERRORS¶
Snowflake¶
LOG ERRORS¶
17. FORALL with INSERT with LOG ERRORS¶
Warning
This pattern is not yet implemmented
Oracle¶
LOG ERRORS¶
Snowflake¶
LOG ERRORS¶
Known Issues¶
No issues were found.
Related EWIs¶
SSC-EWI-0030: The statement below has usages of dynamic SQL.
SSC-EWI-0036: Data type converted to another data type.
SSC-EWI-0056: Create Type Not Supported.
SSC-EWI-0058: Functionality is not currently supported by Snowflake Scripting.
SSC-EWI-0062: Custom type usage changed to variant.
SSC-EWI-OR0049: Package constants in stateful package are not supported yet.
SSC-FDM-0006: Number type column may not behave similarly in Snowflake.
SSC-FDM-0015: Referenced custom type in query not found.
SSC-PRF-0001: This statement has usages of cursor fetch bulk operations.
SSC-PRF-0003: Fetch inside a loop is considered a complex pattern, this could degrade Snowflake performance.
IF¶
Description¶
The IF statement either runs or skips a sequence of one or more statements, depending on the value of a BOOLEAN expression. For more information regarding Oracle IF, check here.
Sample Source Patterns¶
Sample auxiliary table¶
Possible IF variations¶
Oracle¶
Code 1¶
Code 2¶
Code 3¶
Code 4¶
Result 1¶
COL1 |
|---|
one |
Result 2¶
COL1 |
|---|
Unexpected input. |
Result 3¶
COL1 |
|---|
three |
Result 4¶
COL1 |
|---|
Unexpected input. |
Snowflake Scripting¶
Code 1¶
Code 2¶
Code 3¶
Code 4¶
Result 1¶
COL1 |
|---|
one |
Result 2¶
COL1 |
|---|
Unexpected input. |
Result 3¶
COL1 |
|---|
three |
Result 4¶
COL1 |
|---|
Unexpected input. |
Known issues¶
No issues were found.
Related EWIs¶
No related EWIs.
IS EMPTY¶
This is a translation reference to convert the Oracle IS EMPTY statement to Snowflake
Warning
This section is a work in progress; information may change in the future.
Description¶
Use the IS [NOT] EMPTY conditions to test whether a specified nested table is empty, regardless whether any elements of the collection are NULL. (Documentation).
Oracle syntax¶
Sample Source Patterns¶
Oracle¶
The following example shows the usage of the IS EMPTY statement. The statement is applied over a nested table which uses a UDT as the definition type. The output shows the name of the employees who do not have a phone number.
Output¶
EMP_NAME |
|---|
Jane Smith |
Snowflake¶
The Snowflake query shown below is the equivalence of the functionality of the IS EMPTY statement. Particularly, the IS EMPTY statement has a difference between a NULL and an EMPTY object.
Notice that the User-Defined Types are transformed to a VARIANT. The VARIANT type in Snowflake is able to store objects and arrays. Since a nested table is a sequence of information, the ARRAY type is the most suitable type to redefine them and verify is the object ARRAY is empty.
The ARRAY_SIZE equivalent solution also allows to ask for nullability of the nested table (transformed to VARIANT). In other words, the VARIANT type can also store NULLs and empty ARRAYs.
Output¶
EMP_NAME |
|---|
Jane Smith |
Other possible combinations¶
| Description | Oracle | Snowflake |
|---|---|---|
| Ask for a IS NOT EMPTY | | |
| Ask for NULL instead of EMPTY | | |
Known Issues¶
1. User-defined types are being transformed into Variant.¶
User-defined types are not supported thus they are transformed into Variant types which could need manual effort to ensure some functionalities.
Review the following page for more information:
2. Nested tables are not supported.¶
Nested tables are not currently supported. The best approach based on this equivalence is to handle nested tables as Variant but declare Arrays with JSON data inside and execute the PARSE_JSON Snowflake function to populate the nested information.
Review the following pages for more information:
3. Insert statements are not supported for User-defined types.¶
Since User-defined types are not supported in consequence the Insert statements to these types are not supported. Specifically in nested tables, the INSERT INTO ... VALUES statement has to be changed to a INSERT INTO ...SELECT because the ARRAY_CONSTRUCT function is expected to be used in that pattern.
Review the following page for more information:
4. Logic should be adapted to ARRAY types.¶
Since the nested tables should be equivalently transformed to VARIANT and behave as ARRAYs,the functionality and logic of implementing procedures and interaction with the data should be adapted.
Review the following examples:
4.1 Procedures equivalence¶
Oracle¶
Snowflake¶
Output¶
PROC1 |
|---|
IS EMPTY |
4.2 Select statements¶
Outputs may differ from tables to ARRAYs.
Oracle¶
Output¶
PHONE_NUMBER |
|---|
1234567890 |
Snowflake¶
Output¶
PHONE_NUMBERS_COL |
|---|
[ 1234567890 ] |
Related EWIs¶
SSC-EWI-0056: Create Type Not Supported.
SSC-EWI-0062: Custom type usage changed to variant.
SSC-EWI-0073: Pending Functional Equivalence Review.
SSC-EWI-OR0035: The table function is not supported when it is used as a collection of expressions.
SSC-FDM-0006: Number type column may not behave similarly in Snowflake.
SSC-FDM-0015: Referenced custom type in query not found.
SSC-FDM-OR0035: DBMS_OUTPUT.PUTLINE check UDF implementation.
LOCK TABLE¶
Note
Non-relevant statement.
Warning
Notice that this statement removed from the migration; because it is a non-relevant syntax. It means that it is not required in Snowflake.
Description¶
In Oracle, the LOCK TABLE statement allows to explicitly acquire a shared or exclusive table lock on the specified table. The table lock lasts until the end of the current transaction. Review more information here.
Syntax
Sample Source Patterns¶
Locking table¶
Notice that in this example the LOCK TABLE statement has been deleted. This is because Snowflake handles locking in a different method through transactions.
Oracle¶
Snowflake¶
LOG ERROR¶
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
The
FORALLstatement runs one DML statement multiple times, with different values in theVALUESandWHEREclauses. (Oracle PL/SQL Language Reference FORALL Statement).
Oracle Syntax¶
Warning
Snowflake Scripting has no direct equivalence with the FORALL statement, however can be emulated with different workarounds to get functional equivalence.
Sample Source Patterns¶
Setup Data¶
Oracle¶
Tables¶
Snowflake¶
Tables¶
1. MERGE INTO Inside a FORALL¶
Oracle¶
Note
The three cases below have the same transformation to Snowflake Scripting and are functionally equivalent.
Case 1¶
Snowflake¶
FORALL With Collection of Records¶
2. FORALL With INSERT INTO¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
3. FORALL With Multiple Fetched Collections¶
Oracle¶
With INSERT INTO¶
With UPDATE¶
Results INSERT INTO¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
1 |
2 |
Results UPDATE¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
Snowflake¶
With INSERT INTO¶
With UPDATE¶
Results INSERT INTO¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
Results UPDATE¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
4. FORALL With Record of Collections¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
Scripting FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
5. FORALL With Dynamic SQL¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000 |
6. FORALL Without LOOPS¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1 |
2 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
Snowflake¶
FORALL Equivalent¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
1.000000000000000000 |
2.000000000000000000 |
1.000000000000000000 |
2.000000000000000000 |
2.000000000000000000 |
3.000000000000000000 |
3.000000000000000000 |
4.000000000000000000 |
4.000000000000000000 |
5.000000000000000000 |
5.000000000000000000 |
6.000000000000000000 |
7. FORALL With UPDATE Statements¶
Oracle¶
FORALL Example¶
Results¶
COLUMN1 |
COLUMN2 |
|---|---|
54321 |
2 |
Snowflake¶
FORALL Equivalent¶
Results¶
8. FORALL With DELETE Statements¶
Oracle¶
FORALL Example¶
Results¶
Snowflake¶
FORALL Equivalent¶
Results¶
Known Issues¶
No issues were found.
Related EWIs¶
SSC-EWI-0030: The statement below has usages of dynamic SQL.
SSC-EWI-0036: Data type converted to another data type.
SSC-EWI-0058: Functionality is not currently supported by Snowflake Scripting.
SSC-EWI-0062: Custom type usage changed to variant.
SSC-EWI-OR0129: TYPE attribute could not be resolved.
SSC-FDM-0006: Number type column may not behave similarly in Snowflake.
SSC-FDM-OR0031: The error logging clause in DML statements is not supported by Snowflake.
SSC-PRF-0001: This statement has usages of cursor fetch bulk operations.
SSC-PRF-0003: Fetch inside a loop is considered a complex pattern, this could degrade Snowflake performance.
LOOP¶
Translation reference to convert Oracle LOOP statement to Snowflake Scripting
Description¶
With each iteration of the basic
LOOPstatement, its statements run and control returns to the top of the loop. TheLOOPstatement ends when a statement inside the loop transfers control outside the loop or raises an exception.
(Oracle PL/SQL Language Reference BASIC LOOP Statement)
Oracle BASIC LOOP Syntax¶
Snowflake Scripting BASIC LOOP Syntax¶
Oracle BASIC LOOP behavior can also be modified by using the statements:
Sample Source Patterns¶
Loop simple case¶
Note
This case is functionally equivalent.
Oracle¶
Result¶
ITERATOR |
|---|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Snowflake Scripting¶
Result¶
ITERATOR |
|---|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Known Issues¶
No issues were found.
Related EWIs¶
No related EWIs.
OUTPUT PARAMETERS¶
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¶
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¶
Result¶
COL1 |
COL2 |
|---|---|
123 |
-1 |
123 |
456 |
Snowflake Scripting¶
Result¶
COL1 |
COL2 |
|---|---|
123.000000000000000000 |
-1 |
123.000000000000000000 |
456.000000000000000000 |
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.
NESTED PROCEDURES¶
Description¶
In Oracle’s PL/SQL, NESTED PROCEDURES definition refers to a procedure that is declared and defined within the declarative section of another PL/SQL block. This parent block can be an another procedure, a function, or a package body. For more information please refer to Oracle procedure declarations and definitions.
Note
The transformations described below are specific to procedures embedded within other procedures or packages.
Sample Source Patterns¶
IN Parameter Mode for Nested Procedures¶
The IN keyword will be removed, as Snowflake nested procedures only support IN parameters implicitly.
Oracle¶
Snowflake Scripting¶
OUT Parameter Mode for Nested Procedures¶
SnowScript’s nested procedures do not support output parameters. To replicate this functionality in Snowflake, a RETURN type must be created based on the output parameters.
If there’s only one output parameter, that parameter will be returned at the end. In cases with multiple output parameters, an object construct will be generated containing their values. During the call, these values will be assigned to a variable, and subsequently, these results will be assigned to the corresponding variables or parameters.
Oracle¶
Snowflake Scripting¶
Multiple OUT Parameters in Nested Procedures¶
Oracle¶
Snowflake Scripting¶
Multi-level Nested Procedures¶
Snowflake only permits one level of nesting for nested procedures. Therefore, a nested procedure within another nested procedure is not supported. If this occurs, the transformation will include the error !!!RESOLVE EWI!!! /*** SSC-EWI-0111 - ONLY ONE LEVEL OF NESTING IS ALLOWED FOR NESTED PROCEDURES IN SNOWFLAKE. ***/!!!
Oracle¶
Snowflake Scripting¶
Default Values in Nested Procedures¶
Nested procedure arguments do not support default clauses. Therefore, if a nested procedure call omits an optional parameter, the default value for that argument must be submitted within the procedure call. SnowConvert AI automatically identifies these scenarios and fills the procedure calls appropriately.
Oracle¶
Snowflake Scripting¶
Nested Procedure Overloading¶
Snowflake does not support the overloading of nested procedures. If this occurs, the EWI SSC-EWI-0112 - NESTED PROCEDURE OVERLOADING IS NOT SUPPORTED will be added.
Oracle¶
Snowflake Scripting¶
Nested procedure without a parameter list¶
In Snowflake, a nested procedure definition requires empty parentheses () to be syntactically valid when it has no parameters; contrary to Oracle, where they are not needed. SnowConvert AI will add these automatically during translation.
Oracle¶
Snowflake Scripting¶
Nested procedure with REFCURSOR output parameter¶
Oracle¶
Snowflake Scripting¶
Nested procedure with NOCOPY parameter option¶
In Oracle PL/SQL, the NOCOPY keyword is an optimization hint for OUT and IN OUT procedure parameters. By default, Oracle passes these parameters by value, creating an expensive copy of the data during the call and copying it back upon completion. This can cause significant performance overhead for large data structures.
NOCOPY instructs Oracle to pass by reference instead, allowing the procedure to directly modify the original data. This eliminates copying overhead and improves performance. However, changes are immediate and are not implicitly rolled back if an unhandled exception occurs within the procedure.
Therefore, we will remove the NOCOPY parameters option and add the FDM SSC-FDM-OR0050 - EXCEPTIONS WITH NOCOPY PARAMETERS MAY LEAD TO DATA INCONSISTENCY. This is because procedure execution terminates upon hitting an exception, preventing the RETURN statement from being reached. As a result, the variable in the caller’s declare block retains its initial values, as the procedure fails to successfully return a new value for assignment.
Oracle¶
Snowflake Scripting¶
Known Issues¶
1. Multi-level Nested Procedures¶
Our transformation efforts for nested procedures in Snowflake are limited to those nested directly within other procedures, supporting only one level of nesting. If the nesting level exceeds one, or if a procedure is nested within a standalone function, transformation is not supported, and the EWI !!!RESOLVE EWI!!! /*** SSC-EWI-0111 - ONLY ONE LEVEL OF NESTING IS ALLOWED FOR NESTED PROCEDURES IN SNOWFLAKE. ***/!!! will be added.
2. Nested procedures overloading¶
Additionally, overloading of nested procedures is not supported in Snowflake. In such cases, the EWI !!!RESOLVE EWI!!! /*** SSC-EWI-0112 - NESTED PROCEDURE OVERLOADING IS NOT SUPPORTED. ***/!!! will be added.
3. Nested procedures within anonymous blocks¶
Transformation for nested procedures within anonymous blocks is currently pending. The EWI !!!RESOLVE EWI!!! /*** SSC-EWI-OR0057 - TRANSFORMATION FOR NESTED PROCEDURE OR FUNCTION IS NOT SUPPORTED IN THIS SCENARIO ***/!!! will be added.
Related EWIs¶
SSC-FDM-OR0050: Exceptions with
NOCOPYparameters may lead to data inconsistency.SSC-EWI-OR0057: Transformation for nested procedure or function is not supported.
SSC-EWI-0111: Only one level of nesting is allowed for nested procedures in Snowflake.
SSC-EWI-0112: Nested procedure overloading is not supported.
PROCEDURE CALL¶
Translation reference for PROCEDURE CALL aka SUBPROGRAM INVOCATION
Note
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¶
Snowflake Scripting has support for this statement, albeit with some functional differences.
Snow Scripting Subprogram Invocation Syntax¶
Sample Source Patterns¶
Note
Consider the next table and procedure for the examples below.
Oracle¶
Snowflake¶
Simple call¶
Oracle¶
Result¶
COL1 |
|---|
1 |
Snowflake Scripting¶
Result¶
COL1 |
|---|
1 |
Calling a procedure with an optional parameter¶
Warning
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¶
Result¶
COL1 |
|---|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Snowflake Scripting¶
Result¶
COL1 |
|---|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Known Issues¶
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 AI 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.
SSC-FDM-0007: Element with missing dependencies.
RAISE¶
Description¶
The
RAISEstatement explicitly raises an exception.Outside an exception handler, you must specify the exception name. Inside an exception handler, if you omit the exception name, the
RAISEstatement reraises the current exception.(Oracle PL/SQL Language Reference Raise Statement)
The statement is fully supported by Snowflake Scripting, but please take into account that there might be some differences when having some Commit and Rollback Statement.
Snowflake Scripting has support for this statement.
Sample Source Patterns¶
Simple exception throw¶
Oracle¶
Result¶
Snowflake Scripting¶
Result¶
Known Issues¶
No issues were found.
Related EWIs¶
No related EWIs.
RAISE_APPICATION_ERROR¶
Translation reference for the raise_application_error statement.
General description¶
The procedure RAISE_APPLICATION_ERROR lets you issue user-defined ORA- error messages from stored subprograms. That way, you can report errors to your application and avoid returning unhandled exceptions (Oracle documentation).
Oracle syntax¶
Note
The error_number is a negative integer in the range -20000 .. -20999 and message is a character string up to 2048 bytes long.
If the optional third parameter is TRUE, the error is placed on the stack of previous errors. If the parameter is FALSE (the default), the error replaces all previous errors.
The equivalent statement in Snowflake is the RAISE clause, nevertheless, it is required to declare the user-defined exception as a variable before calling the RAISE statement for it.
Snowflake Syntax¶
Note
For more information review the following Snowflake documentation.
Sample Source Patterns¶
1. Exception in functions without declaring section¶
In this scenario, the function without a declaring section is translated to a procedure with the exception declaration. Please note that:
The exception variable name is declared in upper case.
The exception variable name is based on the description and an ending is composed of an exception code name followed by a consecutive number.
The declaring section is created even though the initial function or procedure does not contain it.
Oracle¶
Output¶
Snowflake¶
Output¶
2. Exception code number outside limits¶
The following example shows the translation commented out in the procedure body. It is because the code is outside the applicable code limits in Snowflake. The solution is to change the exception code for an available code in the query section.
Oracle¶
Output¶
Snowflake¶
Output¶
3. Exception stack functionality¶
The exception stack functionality is not supported in Snowflake and is removed from the exception declaration.
Oracle¶
Output¶
Snowflake¶
Output¶
4. Multiple exceptions with the same exception code¶
Multiple exceptions with the same can coexist in the declaring section and raise statements.
Oracle¶
Output¶
Snowflake¶
Output¶
Known Issues¶
SQLREM function may be reviewed.
Exception code number outside the applicable limits in Snowflake has to be changed to an available code exception.
Add to a stack of errors is not supported.
Related EWIs¶
SSC-EWI-OR0099: The exception code exceeds the Snowflake Scripting limit.
SSC-FDM-0029: User defined function was transformed to a Snowflake procedure.
SSC-FDM-OR0011: The boolean argument was removed because the “add to stack” options is not supported.
UDF CALL¶
Translation reference for User-defined function (UDF) Call
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
As is widely acknowledged, non-scalar user-defined functions (UDFs) in Oracle are converted into Snowflake stored procedures to accommodate more intricate functionalities.
This transformation also alters the way the function is invoked, transitioning from a traditional function call to a stored procedure call.
For additional details regarding the invocation of stored procedures, refer to the documentation accessible here: PROCEDURE CALL.
Sample Source Patterns¶
Note
Consider the next function and tables for the examples below.
Oracle¶
Snowflake¶
UDF Call¶
Oracle¶
Result¶
Snowflake Scripting¶
Result¶
UDF Call within a query¶
When a function call is embedded within a query, the invocation process becomes more intricate due to Snowflake’s limitation of not being able to call procedures directly within queries. To overcome this limitation, the procedure invocation is moved outside the query, and the result is assigned to a variable. This variable is then referenced within the query, thereby achieving functional equivalence. This approach allows for the execution of more complex behaviors within Snowflake queries while adhering to the procedural constraints.
Oracle¶
Result¶
Snowflake Scripting¶
Result¶
Known Issues¶
1. Unsupported Usage of UDFs in Queries with Query Dependencies¶
When calling User-Defined Functions (UDFs) within queries with query dependencies, scenarios involving embedded functions with columns as arguments are not supported. This limitation arises because the column values cannot be accessed from outside the query. Examples of unsupported scenarios include:
The supported scenarios include function calls with other types of arguments such as literal values, external variables, or parameters. For instance:
In the supported scenarios, the function can effectively be migrated.
Related EWIs¶
SSC-EWI-0073: Pending Functional Equivalence Review.
SSC-FDM-0006: Number type column may not behave similarly in Snowflake.
SSC-FDM-0029: User defined function was transformed to a Snowflake procedure.
WHILE¶
Translation reference to convert Oracle WHILE statement to Snowflake Scripting
Description¶
The
WHILELOOPstatement runs one or more statements while a condition isTRUE.
(Oracle PL/SQL Language Reference WHILE Statement)
Oracle WHILE Syntax¶
Snowflake Scripting WHILE Syntax¶
Oracle WHILE behavior can also be modified by using the statements:
Sample Source Patterns¶
While simple case¶
Note
This case is functionally equivalent.
Oracle¶
Result¶
ITERATOR |
|---|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Snowflake Scripting¶
Result¶
ITERATOR |
|---|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Known Issues¶
No issues were found.
Related EWIs¶
No related EWIs.