The RESULT clause is optional in procedures. Omitting the result clause allows you to write procedures that return different result sets, with different numbers or types of columns, depending on how they are executed.
If you do not use the variable result sets feature, you should use a RESULT clause to provide better performance, and to allow front-end tools to discern the columns and data types the procedure will produce without executing it.
For example, the following procedure returns two columns if the input variable is Y, but only one column otherwise:
CREATE PROCEDURE names( IN formal char(1)) BEGIN IF formal = 'y' THEN SELECT emp_lname, emp_fname FROM employee ELSE SELECT emp_fname FROM employee END IF END
The use of variable result sets in procedures is subject to some limitations, depending on the interface used by the client application.
Embedded SQL You must DESCRIBE the procedure call after the cursor for the result set is opened, but before any rows are returned, in order to get the proper shape of result set.
For information about the DESCRIBE statement, see Chapter 6, “SQL Statements,” in the Sybase IQ Reference Manual.
ODBC Variable result set procedures can be used by ODBC applications. The Sybase IQ ODBC driver carries out the proper description of the variable result sets.
Open Client applications Open Client applications can use variable result set procedures. Sybase IQ carries out the proper description of the variable result sets.