Table of ContentsPreviousNext

Database Migration


Executing Procedures and User-Defined Functions

This section describes an execution of procedures and user-defined functions from other procedures or functions in various databases and their conversion by SQLWays.

TABLE 27. Executes Procedures and User-Defined Functions
Database
Syntax
Description
Microsoft SQL Server

EXEC [UTE]
[ @return_status = ]
procedure_name
[
[@par1=] {value | @variable [OUTPUT] | [DEFAULT]
[,[@parN=] {value | @variable [OUTPUT] | [DEFAULT]]...
]

The EXECUTE statement is used to execute procedures and user-defined functions in Microsoft SQL Server.
 
@return_status is the value, returning by the function (procedure)
procedure_name - the name of the procedure (function)
@parN - the name of a procedure (function) parameter
 
Examples:
The sample below calls the procedure proc2:
EXEC proc2
 
The following example calls f1 function with parameters 1 and @var1. The function returns a value in the @ret_val variable:
 
EXECUTE @ret_value = f1 1, @var1
Oracle

[ return_status = ]
procedure_name
([{ value | variable }])

In order to execute a procedure or function in Oracle, you have to explicitly specify the name of the procedure (function) and its parameters in PL/SQL.
 
Examples:
The following example calls the proc2 stored procedure with parameters 77 and `test'.
proc2 (77,'test');
 
In the example below, function func2 returns a value into the ret_func2 variable. The function takes one parameter - 0.
 
ret_func2:=func2(0) ;
Sybase Adaptive Server Anywhere

[@variable =] CALL procedure_name

([

[@par1=] exp1 [,[@parN=] expN]...

])

CALL invokes a procedure that has been previously created.
 
The argument list can be specified by position or by using keyword format:
· by position, the arguments will match up with the corresponding parameter in the parameter list for the procedure;
· by keyword, the arguments are matched up with the named parameters (par1, ..., parN).
 
Inside a procedure, a CALL statement can be used in a DECLARE statement when the procedure returns result sets (for example: in the DECLARE CURSOR statement).
 
Procedures can return an integer value (as a status indicator) using the RETURN statement.

EXEC[UTE] [@return_status =] [creator.]procedure_name

[

[@par1=] {exp1 | @variable1 [OUTPUT]}

[,[@parN=] {expN | @variableN [OUTPUT]}]...

]

EXECUTE invoke a procedure, optionally supplying procedure parameters and retrieving output values and return status information.
 
EXECUTE is Sybase Adaptive Server Enterprise-compatible alternative to the CALL statement.
 
@return_status is a value, which contains return status information.
 
@parN is the name of a procedure parameter.
 
Examples:
The sample below executes the procedure p2:
EXECUTE p2
 
The following example executes the procedure and stores the return value in the @ret_val variable:
EXECUTE @ret_value = p1 1


Ispirer Systems
http://www.ispirer.com
ispirer@ispirer.com
Table of ContentsPreviousNext