ODBC Server Reference Manual

Stored Procedures
HP NonStop ODBC Server Reference Manual429151-002
5-5
Invoking Stored Procedures in Transact-SQL
The result appears as follows:
FIRST_NAME LAST_NAME
---------- ---------
JOE SMITH
DON HUE
DEBBIE SMITH
If the optional return status (?=) is specified and the stored procedure has been
coded and configured to return a status code, the caller receives the execution
status in addition to the results.
Stored procedure execution can return multiple result sets or counts. Errors regarding
the stored procedure are obtained in the same way as for other SQL statements.
Invoking Stored Procedures in Transact-SQL
Transact-SQL uses the EXECUTE statement to invoke stored procedures. The
following describes the syntax of the EXECUTE statement. The statement is described
in greater detail in Section 4, Transact-SQL Language.
Execution of the stored procedure results in the following:
If the stored procedure contains SELECT statements, the caller receives a result
set for every SELECT statement. A result set consists of a description of the
columns in the result rows together with zero or more rows of values. UPDATE,
INSERT, and DELETE statements return a count of affected rows.
In the following example, the procedure GET_EMPNAME is called to obtain the
names of employees whose IDs are between 1000 and 1010. The result set
consists of columns LAST_NAME and FIRST_NAME, and three rows of data.
@RETURN_STATUS = EXECUTE GET_EMPNAME
@LOW_EMP_ID = 1000,
@HIGH_EMP_ID = 1010
The result appears as follows:
FIRST_NAME LAST_NAME
---------- ---------
JOE SMITH
[ EXEC[UTE] ] [ @return-status = ]
[ server
.] [ [database.]owner. ] procedure-name[;number
]
[ database.. ]
[ [@parameter-name =] { value } [, ...]
]
{ @variable [ OUT[PUT] ] }
[ WITH RECOMPILE ]