CREATE PROCEDURE

Oracle Create Procedure to Snowflake Snow Scripting

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentation

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected].

Thank you for your understanding.

Description

Some parts in the output code are omitted for clarity reasons.

A procedure is a group of PL/SQL statements that you can call by name. A call specification (sometimes called call spec) declares a Java method or a third-generation language (3GL) routine so that it can be called from SQL and PL/SQL. The call spec tells Oracle Database which Java method to invoke when a call is made. It also tells the database what type conversions to make for the arguments and return value. Oracle SQL Language Reference Create Procedure.

For more information regarding Oracle Create Procedure, check here.

CREATE [ OR REPLACE ] [ EDITIONABLE | NONEDITIONABLE ]
PROCEDURE
[ schema. ] procedure_name
[ ( parameter_declaration [, parameter_declaration ]... ) ] [ sharing_clause ]
[ ( default_collation_option | invoker_rights_clause | accessible_by_clause)... ] 
{ IS | AS } { [ declare_section ] 
    BEGIN statement ...
    [ EXCEPTION exception_handler [ exception_handler ]... ]
    END [ name ] ;
      |
    { java_declaration | c_declaration } } ;

For more information regarding Snowflake Create Procedure, check here.

Sample Source Patterns

1. Basic Procedure

2. Procedure with Different Parameters

Output parameters

Snowflake does not allow output parameters in procedures, a way to simulate this behavior could be to declare a variable and return its value at the end of the procedure.

Parameters with default values

Snowflake does not allow setting default values for parameters in procedures, a way to simulate this behavior could be to declare a variable with the default value or overload the procedure.

3. Procedure with Additional Settings

4. Procedure with Basic Statements

5. Procedure with empty RETURN statements

In Oracle procedures you can have empty RETURN statements to finish the execution of a procedure. In Snowflake Scripting procedures can have RETURN statements but they must have a value. By default all empty RETURN statements are converted with a NULL value.

RETURN statements in procedures with output parameters

In procedures with output parameters, instead of a NULL value an OBJECT_CONSTRUCT will be used in the empty RETURN statements to simulate the output parameters in Snowflake Scripting.

6. Procedure with DEFAULT parameters

DEFAULT parameters allow named parameters to be initialized with default values if no value is passed.

Known Issues

1. Unsupported OUT parameters

Snowflake procedures do not have a native option for output parameters.

2. Unsupported Oracle additional settings

The following Oracle settings and clauses are not supported by Snowflake procedures:

  • sharing_clause

  • default_collation_option

  • invoker_rights_clause

  • accessible_by_clause

  • java_declaration

  • c_declaration

  1. SSC-EWI-0058: Functionality is not currently supported by Snowflake Scripting

  2. SSC-EWI-OR0097: Procedures properties are not supported in Snowflake procedures.

  3. SSC-FDM-OR0012: COMMIT and ROLLBACK statements require adequate setup to perform as intended.

  4. SSC-PRF-0003: Fetch inside a loop is considered a complex pattern, this could degrade Snowflake performance.

  5. SSC-PRF-0004: This statement has usages of cursor for loop.

  6. SSC-EWI-0030: The statement below has usages of dynamic SQL

Last updated