Packages
This is a translation reference to convert Oracle Packages to Snowflake.
Some parts in the output code are omitted for clarity reasons.
Package Declaration
This section shows the equivalence between Oracle Package Declaration members and Snowflake statements.
Package Translation options
There are two options to migrate packages, each option will affect directly the naming of the objects inside the package. Check here how you can change this mode in the UI, or check here to change it using the Command Line Interface.
Let's suppose that we have the next scenario in Oracle:
A package named
MY_PACKAGE.
A procedure inside the package named
MY_PROCEDURE.
Option 1 (Using new schema)
With this option, packages are transformed into new schemas. Package elements like functions and procedures are created inside the new schema. If the package is already inside a schema, the name of the package will be joined with the name of the schema with an underscore.
This is the default option for translating packages.
Result:
An schema will be created with the name
MY_PACKAGE
.Qualified name of the procedure will be updated to
MY_PACKAGE.MY_PROCEDURE
.It the package is inside an schema then the procedure will be updated to
MY_SCHEMA_MY_PACKAGE.MY_PROCEDURE
.
Option 2
With this option, the name of the package elements will be joined with the package name with an underscore. New schemas will not be created.
Result:
Name of the procedure will be updated to
MY_PACKAGE_MY_PROCEDURE
.It the package is inside an schema then the procedure will be updated to
MY_SCHEMA.MY_PACKAGE_MY_PROCEDURE
.
Create Package
The CREATE PACKAGE statement will be converted to a CREATE SCHEMA statement. Any member inside the package will be converted outside of the package.
Oracle
Transformation with option 1 (Using new schema)
Transformation with option 2
With this option, the Schema won't be generated and only the inner elements will be kept but with their names renamed.
Procedure and function declaration
Procedure and function declarations are not necessary for the transformation to Snowflake. Existing procedure or function declarations will be commented out.
Oracle
Transformation with option 1 (Using new schema)
Note that that for option 1, the PROCEDURE
definition in the package is removed since it is not required by Snowflake.
Variables declaration
You might also be interested in variables helper.
Oracle package variables are transformed into Snowflake Session Variables. A prefix is added to the values to know what type it is inside stored procedures. If the value should be null, a "~" is added. Because of this, variables that depend on other variables will require a SUBSTR and a CAST.
Data type and Code mappings
Data type or value | Code |
Numeric types | # |
Datetime types | & |
String types | $ |
NULL values | ~ |
The transformation of the variables will be always the same regardless of the transformation option.
Oracle
Snowflake
Constants declaration
Constants declaration will be declared inside the procedure or functions that use them. Existing package constants declaration will be commented out and a warning will be added.
Oracle
Transformation with option 1
Note that the PROCEDURE
definition in the package is removed since it is not required by Snowflake.
Other Package members
The transformation for other package members like cursors, exceptions and user defined types, is still a work in progress.
Oracle
Transformation with option 1
Transformation with option 2
Package Body Definition
This section shows the equivalence between Oracle Package Body Definition members and Snowflake statements.
Create Package Body
Elements inside a Package Body are going to be extracted from the package. The package body will disappear so the Create Package Body statement is removed in the converted code.
Procedure Definition
Stored Procedures inside packages use the same transformations defined in the PL/SQL Translation Reference.
Oracle
Transformation with option 1
Transformation with option 2
Function Definition
Functions inside package bodies are converted into Snowflake stored procedures.
Oracle
Transformation with option 1
Transformation with option 2
SnowConvert helpers Code removed from the example. You can find them here.
Other package body members
Please refer to the "other package members" section in Package declaration.
Using package members
Call of procedures inside packages
If the procedure is inside a package and the package is inside a schema, the call will be renamed.
Oracle
Transformation with option 1
SnowConvert helpers Code removed from the example. You can find them here.
Transformation with option 2
SnowConvert helpers Code removed from the example. You can find them here.
With this option, the call of the procedures will be renamed accordingly to the rename of the procedure declaration. The schema name will be separated from the procedure name with a dot.
Snowflake
Package variables inside procedures
Packages variables are transformed to session variables. Those variables are usable through the "Package variables helper".
This sample is using variables declared in packages Variables declaration section.
Oracle
Snowflake
Related EWIs
Last updated