Invokes a procedure.
Syntax 1
[ variable = ] CALL procedure-name ( [ expression ] [ , … ] )
Syntax 2
[ variable = ] CALL procedure-name ( [ parameter-name = expression ] [ , … ] )
This example calls the sp_customer_list procedure. This procedure has no parameters, and returns a result set:
CALL sp_customer_list()
This dbisql example creates a procedure to return the number of orders placed by the customer whose ID is supplied, creates a variable to hold the result, calls the procedure, and displays the result:
CREATE PROCEDURE OrderCount (IN CustomerID INT, OUT Orders INT) BEGIN SELECT COUNT("DBA".SalesOrders.ID) INTO Orders FROM "DBA".Customers KEY LEFT OUTER JOIN "DBA".SalesOrders WHERE "DBA".Customers.ID = CustomerID ; END go -- Create a variable to hold the result CREATE VARIABLE Orders INT go -- Call the procedure, FOR customer 101 -- ----------------------------- CALL OrderCount ( 101, Orders) go -------------------------------- -- Display the result SELECT Orders FROM DUMMY go
CALL invokes a procedure that has been previously created with a CREATE PROCEDURE statement. When the procedure completes, any INOUT or OUT parameter values are copied back.
You can specify the argument list by position or by using keyword format. By position, arguments match up with the corresponding parameter in the parameter list for the procedure. By keyword, arguments match the named parameters.
Procedure arguments can be assigned default values in the CREATE PROCEDURE statement, and missing parameters are assigned the default value, or, if no default is set, NULL.
Inside a procedure, CALL can be used in a DECLARE statement when the procedure returns result sets. See Chapter 1, “Using Procedures and Batches” in the System Administration Guide: Volume 2.
Procedures can return an integer value (as a status indicator, say) using the RETURN statement. You can save this return value in a variable using the equality sign as an assignment operator:
CREATE VARIABLE returnval INT ; returnval = CALL proc_integer ( arg1 = val1, ... )
None
Sybase Not supported by Adaptive Server Enterprise. For an alternative that is supported, see EXECUTE statement [ESQL].
Must be the owner of the procedure, have EXECUTE permission for the procedure, or have DBA authority.