Returning Results As Procedure Parameters - Sybase Adaptive Server IQ 12.4.2 Administration And Performance Manual

Table of Contents

Advertisement

Returning results as procedure parameters

Using the SET
statement
Using single-row
SELECT statements
CREATE VARIABLE returnval INTEGER ;
returnval = CALL myproc() ;
Procedures can return results to the calling environment in the parameters to
the procedure.
Within a procedure, parameters and variables can be assigned values in one of
the following ways:
The parameter can be assigned a value using the SET statement.
The parameter can be assigned a value using a SELECT statement with an
INTO clause.
The following somewhat artificial procedure returns a value in an OUT
parameter that is assigned using a SET statement:
CREATE PROCEDURE greater (IN a INT,
BEGIN
IF a > b THEN
SET c = a;
ELSE
SET c = b;
END IF ;
END
Note
The preceding example is artificial: generally a function is easier to use
than a procedure when only one result is required.
Single-row queries retrieve at most one row from the database. This type of
query is achieved by a
SELECT
clause follows the select list and precedes the
variables to receive the value for each select list item. There must be the same
number of variables as there are select list items.
CHAPTER 6
Using Procedures and Batches
IN b INT,
OUT c INT)
statement with an
INTO
clause. It contains a list of
FROM
clause. The
INTO
247

Advertisement

Table of Contents
loading

Table of Contents