Output Parameters (Procedures)

From InterBase
Jump to: navigation, search

Go Up to Procedures and Triggers


Used to return values from a stored procedure to the calling application. Available in stored procedures only.

CREATE PROCEDURE <name> [(<param data type> [, <param data type >])] 
[RETURNS (<param data type> [, <param data type> ])]

Description: Output parameters are used to return values from a procedure to the calling application. They are declared in a comma-delimited list in parentheses following the RETURNS keyword in the header of CREATE PROCEDURE. Once declared, they can be used in the procedure body anywhere a variable can appear. They can be of any InterBase data type. Arrays of data types are not supported.

If output parameters are declared in the header of a procedure, the procedure must assign them values to return to the calling application. Values can be derived from any valid expression in the procedure.

A procedure returns output parameter values to the calling application with a SUSPEND statement. An application receives values of output parameters from a select procedure by using the INTO clause of the SELECT statement. An application receives values of output parameters from an executable procedure by using the RETURNING_VALUES clause.

In a SELECT statement that retrieves values from a procedure, the column names must match the names and data types of the output parameters of the procedure. In an EXECUTE PROCEDURE statement, the output parameters need not match the names of the output parameters of the procedure, but the data types must match.

Example: The following isql script is a procedure header declares five output parameters, HEAD_DEPT, DEPARTMENT, MNGR_NAME, TITLE, and EMP_CNT:

CREATE PROCEDURE ORG_CHART RETURNS (HEAD_DEPT CHAR(25), DEPARTMENT
CHAR(25), MNGR_NAME CHAR(20), TITLE CHAR(5), EMP_CNT INTEGER)

See Also

For more information on declaring output parameters in a procedure, see CREATE PROCEDURE.

Advance To: