The structure of procedures, Sql statements allowed in procedures – Sybase 12.4.2 User Manual

Page 263

Advertising
background image

CHAPTER 6 Using Procedures and Batches

243

The structure of procedures

The body of a procedure consists of a compound statement as discussed in
“Using compound statements” on page 240. A compound statement consists
of a BEGIN and an END, enclosing a set of SQL statements. The statements
must be separated by semicolons.

The SQL statements that can occur in procedures are described in “SQL
statements allowed in procedures” on page 243.

Procedures can contain control statements, which are described in “Control
statements” on page 239.

SQL statements allowed in procedures

Almost all SQL statements are allowed within procedures, including the
following:

SELECT, UPDATE, DELETE, INSERT and SET VARIABLE.

The CALL statement to execute other procedures.

Control statements (see “SQL statements allowed in procedures” on page
243).

Cursor statements (see “Using cursors in procedures” on page 251).

Exception handling statements (see “Using exception handlers in
procedures” on page 261).

The EXECUTE IMMEDIATE statement.

Some SQL statements are not allowed within procedures. These include the
following:

CONNECT statement

DISCONNECT statement.

COMMIT, ROLLBACK and SAVEPOINT statements are allowed within
procedures with certain restrictions (see “Transactions and savepoints in
procedures”).

For details, see the

Usage

for each SQL statement in the chapter “SQL

Statements” in Adaptive Server IQ Reference Manual.

Advertising