Entering content frame

routine Locate the document in its SAP Library structure

The part of the CREATE DBPROC or CREATE TRIGGER-statement referred to as the routine is the implementation of the database procedure or trigger. . It consists of optional variable declarations and statements.

Syntax

<routine> ::= [<local_variables>] <statement_list>;

<local_variables> ::=VAR <local_variable_list>;
<local_variable_list> ::= <local_variable> | <local_variable_list>; <local_variable>
<local_variable> ::= <variable_name> <data_type>
<variable_name> ::= <identifier>

<statement_list> ::= <statement> | <statement_list> ; <statement>

identifier, data_type, statement

Explanation

Variables

The local variables of the database procedure must be declared explicitly by specifying a data type before they are used. Only BOOLEAN, CHAR[ACTER], DATE, FIXED, FLOAT, INT[EGER], NUMBER, REAL, SMALLINT, TIME, TIMESTAMP, and VARCHAR are permitted as data types data types. Once they have been declared, the variables can be used in any SQL and other statements.

Every database procedure has the variables $RC, $ERRMSG, and $COUNT implicitly.

The $RC variable returns a numeric error code after an SQL statement has been executed. The value 0 means that the SQL statement was successfully executed.
In parallel with $RC, the $ERRMSG variable returns an explanation of the error containing a maximum of 80 characters.
The number of lines processed in an SQL statement is indicated by the $COUNT variable.

Variables can be assigned a value with the assignment_statement (see statement).

Restrictions

The statement list must not contain more than 255 SQL statements.

Leaving content frame