COMPOUND STATEMENTS
This section is a translation specification for the compound statements
This section is a work in progress, information may change in the future.
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
[DECLARE <Variable declaration>]
BEGIN
<Executable statements>
[EXCEPTION <Exception handler>]
ENDSnowflake syntax
BEGIN
<statement>;
[ <statement>; ... ]
[ EXCEPTION <exception_handler> ]
END;Sample Source Patterns
1. IF-ELSE block
Review the following documentation about IF statements to learn more: SnowConvert IF statements translation and Snowflake IF statement documentation
Oracle
Snowflake
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.
2. CASE statement
For more information, review the following documentation: SnowConvert CASE statement documentation and Snowflake CASE documentation
Oracle
Snowflake
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.
3. LOOP statements
For more information review the following documentation: SnowConvert FOR LOOP and Snowflake LOOP documentation and FOR documentation.
Oracle
Snowflake
4. Procedure call and OUTPUT parameters
Anonymous block in Oracle may have calls to procedures. Furthermore, the following documentation may be useful: SnowConvert Procedure documentation.
The following example uses the OUT parameters, the information about the current transformation can be found here: SnowConvert OUTPUT Parameters
Oracle
Snowflake
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
Snowflake
The following warning may be added in the future:
/*** MSC-WARNING - MSCEWI3058 - NLS_DATE_FORMAT SESSION PARAMETER DOES NOT ENFORCE THE INPUT FORMAT IN ORACLE ***/
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
Snowflake
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.
7. Select statements
For more information review the following documentation: Select documentation.
Oracle
Snowflake
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.
8. Join Statements
For more information review the following documentation: Joins documentation.
Oracle
Snowflake
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
Snowflake
ZERO_DIVIDE exception in Snowflake is not supported.
Known issues
Unsupported GOTO statements in Oracle. Review this page.
Exceptions that use GOTO statements may be affected too.
Cursor functionality may be adapted under current restrictions on translations.
Last updated
Was this helpful?