A procedure can return more than one result set to the calling environment.
By default, Interactive SQL does not show multiple result sets. To enable multiple result set functionality, you can use the Options window in Interactive SQL, or you can execute a SQL statement to set the isql_show_multiple_result_sets option. The setting takes effect immediately and remains in effect for future sessions until disabled.
Connect to the database as a user with DBA authority.
In Interactive SQL, click Tools » Options.
Click SQL Anywhere.
In the Results tab, click Show All Result Sets.
Click OK.
Connect to the database as a user with DBA authority.
Execute the following statement:
SET OPTION isql_show_multiple_result_sets=On |
After you enable this option, Interactive SQL shows multiple result sets.
If a RESULT clause is employed in a procedure definition, the result sets must be compatible: they must have the same number of items in the SELECT lists, and the data types must all be of types that can be automatically converted to the data types listed in the RESULT clause.
If the RESULT clause is omitted, a procedure can return result sets that vary in the number and type of columns that are returned.
The following procedure lists the names of all employees, customers, and contacts listed in the database:
CREATE PROCEDURE ListPeople() RESULT ( Surname CHAR(36), GivenName CHAR(36) ) BEGIN SELECT Surname, GivenName FROM Employees; SELECT Surname, GivenName FROM Customers; SELECT Surname, GivenName FROM Contacts; END; |
To test this procedure and view multiple result sets in Interactive SQL, enter the following statement in the SQL Statements pane:
SET OPTION isql_show_multiple_result_sets=On; CALL ListPeople (); |
![]() |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |