Compound statements
- Last Updated: November 7, 2022
- 1 minute read
- DataDirect Connectors
- JDBC
- Autonomous REST Connector 6.0
- Documentation
In addition to defining as single statement in a function using a RETURN,
you can specify compound statements (multiple statements) wrapped in BEGIN
ATOMIC and END. The following demonstrates the syntax along with
supported typical declarations and statements. See the following topics for more information
about supported statements and syntax.
BEGIN ATOMIC
<table_variable_declaration>;
<scalar_variable_declaration>;
<cursor_declaration>;
<handler_declaration>;
<procedural_statement>;
RETURN <expression>;
END
where:
- table-variable-declaration
- (optional) defines the variable name, column names, and data types for a temporary
table to be created. For example,
DECLARE TABLE mytable (id INTEGER, employees VARCHAR(32));. See Table declarations for more information. - scalar_variable_declaration
- (optional) defines the variable name and data type for a value to be stored. For
example,
DECLARE max_event TIMESTAMP;. See Scalar declarations for more information. - cursor_declaration
- (optional) defines the cursor that allows procedures to return table values as result sets. See "Cursor declaration" for details and syntax. See Cursor declarations for more information.
- handler_declaration
- (optional) defines a handler used for exception handling. See Handler declarations for more information.
- procedural_statement
- defines DQL, DML, DDL, and SQL procedural statements used to execute the routine. See Procedural SQL statements for more information.
- expression
- is the argument that determines the value to be returned.