DECLARE

Translation reference to convert Oracle DECLARE statement to Snowflake 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.

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.

declare_section body

declare_section::= { item_list_1 [ item_list_2 ] | item_list_2 }

item_list_1::= 
{ type_definition
| cursor_declaration
| item_declaration
| function_declaration
| procedure_declaration
}
 ...
 
item_list_2::=
{ cursor_declaration
| cursor_definition
| function_declaration
| function_definition
| procedure_declaration
| procedure_definition
}
 ...

item_declaration::=
{ collection_variable_decl
| constant_declaration
| cursor_variable_declaration
| exception_declaration
| record_variable_declaration
| variable_declaration
}

body::= BEGIN statement ...
  [ EXCEPTION exception_handler [ exception_handler ]... ] END [ name ] ;

Sample Source Patterns

Variable declaration

Oracle

Snowflake Scripting

Constant declaration

Oracle

Snowflake Scripting

Cursor declaration

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

Snowflake Scripting

Not supported cases

The next Oracle declaration statements are not supported by the Snowflake Scripting declaration block:

  1. Cursor variable declaration.

  2. Collection variable declaration.

  3. Record variable declaration.

  4. Type definition (all its variants).

  5. Function declaration and definition.

  6. 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.

  1. SSC-EWI-OR0051: PRAGMA EXCEPTION_INIT is not supported.

  2. SSC-EWI-OR0099: The exception code exceeds the Snowflake Scripting limit.

  3. SSC-FDM-0016: Constants are not supported by Snowflake Scripting. It was transformed into a variable.

  4. SSC-FDM-OR0025: Not Null constraint is not supported in Snowflake Procedures.

Last updated