User's Guide
Part III. Using SQL Anywhere
Chapter 20. Using Procedures, Triggers, and BatchesThe following statements are not allowed in batches:
Otherwise, any SQL statement is allowed, including data definition statements such as CREATE TABLE, ALTER TABLE, and so on.
The CREATE PROCEDURE statement is allowed, but must be the final statement of the batch.
You can include one or more SELECT statements in a batch. There are limitations on the use of more than one SELECT statements, just as in stored procedures: multiple SELECT statements are allowed only if they return the same result columns.
The following is a valid batch:
IF EXISTS( SELECT *FROM systableWHERE table_name='employee' )THENSELECT emp_lname AS LastName,emp_fname AS FirstNameFROM employee;SELECT lname, fnameFROM customer;SELECT last_name, first_nameFROM contact;END IF
The alias for the result set is required only in the first SELECT statement, as the database engine uses the first SELECT statement in the batch to describe the result set.
A RESUME is required following each query to retrieve the next result set.
The following is not a valid batch, as the two queries return different result sets:
IF EXISTS( SELECT * FROM systableWHERE table_name='employee' )THENSELECT emp_lname AS LastName,emp_fname AS FirstNameFROM employee;SELECT id, lname, fnameFROM customer;END IF