Writing Code |
Top Previous Next |
Each scripting code block has the same structure. There are required and optional parts.
Separate statements are terminated by the semicolon characters ";".
Syntax The definition of the structure of a scripting block is as follows:
EXECUTE UDSBLOCK [block_name] [(<input_parameter_clause>)] [RETURNS (<output_parameter_clause>)] AS [<declare_clause>] BEGIN [<compound_statement>] [<when_do>] END
<input_parameter_clause> ::= <input_parameter_spec> [, <input_parameter_spec>]
<input_parameter_spec> ::= parameter_name <data_type> [NOT NULL] [{DEFAULT | = } value]
<output_parameter_clause> ::= <output_parameter_spec> [, <output_parameter_spec>]
<output_parameter_spec> ::= parameter_name <data_type>
<declare_clause> ::= { <declare_variable> | <declare_cursor> | <declare_subroutine> } [<declare_clause>]
<declare_subroutine> ::== { <declare_function> | <declare_procedure> }
<compound_statement> ::= { <block> | <statement> } [{ <block> | <statement> }]
Declare ClauseThe <declare_clause> is optional and allows for 3 different types of declaration:
The clause can include multiple entries of these declarations.
Scripting Code Block BodyThe <compound_statement> block consists of one or more statements. This can include additional BEGIN ... END blocks, structural or data manipulations statements, and exception handling statements.
Some of these statements are forwarded directly to the database system, like SELECT, and cannot use functions from the library.
General and Structural StatementsThe following statements are available with regard to structure, looping and code decision making.
Data Manipulation StatementsData can be retrieved from the database and modified if required. You can loop over data or get single row values.
Exception HandlingScript behaviour can be different depending on the outcome of statements. You can use exception handling statements to execute code after specific exceptions, or make sure code is executed always, despite of exceptions.
|