Collection Contents Index Returning result sets from Transact-SQL procedures Error handling in Transact-SQL procedures pdf/chap30.pdf

User's Guide
   PART 5. The Adaptive Server Family
     CHAPTER 30. Transact-SQL Compatibility       

Variables in Transact-SQL procedures


Adaptive Server Anywhere uses the SET statement to assign values to variables in a procedure. In Transact-SQL, values are assigned using the SELECT statement with an empty table-list. The following simple procedure illustrates how the Transact-SQL syntax works:

CREATE PROCEDURE multiply 
               @mult1 int,
               @mult2 int,
               @result int output 
AS 
SELECT @result = @mult1 * @mult2

This procedure can be called as follows:

CREATE VARIABLE @product int ;
EXECUTE multiply 5, 6, @product OUTPUT;

The variable @product has a value of 30 after the procedure is executed.

For Info     For more information on using the SELECT statement to assign variables, see Writing compatible queries. For more information on using the SET statement to assign variables, see SET statement.


Collection Contents Index Returning result sets from Transact-SQL procedures Error handling in Transact-SQL procedures pdf/chap30.pdf