dbretstatus

DB Library for C

DB Library for C

dbretstatus

Determines the stored procedure status number returned by a stored procedure or a remote stored procedure.

Syntax

DBINT dbretstatus ( PDBPROCESS dbproc );

Arguments

dbproc

Is the DBPROCESS structure that is the handle for a particular workstation or Microsoft® SQL Server™ 2000 process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.

Returns

The return status number for the stored procedure or remote stored procedure.

Remarks

Normally, completed stored procedures return a status number of 0. A RETURN statement in a stored procedure is used for application-specific return status numbers. If a RETURN statement is not used and an error occurs when the stored procedure is executed, SQL Server can return one of the following values:

Value Description
-1 Missing object.
-2 Data type error.
-3 Process was chosen as deadlock victim.
-4 Permission error.
-5 Syntax error.
-6 Miscellaneous user error.
-7 Resource error, such as out of space.
-8 Nonfatal internal problem.
-9 System limit was reached.
-10 Fatal internal inconsistency.
-11 Fatal internal inconsistency.
-12 Table or index is corrupt.
-13 Database is corrupt.
-14 Hardware error.

The values -15 through -99 are reserved for future SQL Server expansion.

The dbhasretstat function determines whether the most recently executed stored procedure actually generated a return status number.

The server returns stored procedure information (including any return status and parameter values) immediately after returning all normal results for that stored procedure. Process the normal results, and then call dbretstatus after dbresults returns NO_MORE_RPC_RESULTS (for all stored procedures in a batch except the last one) or NO_MORE_RESULTS (for a single stored procedure, or for the last stored procedure in a batch).

The order in which the application processes the status number and any return-parameter values is unimportant.

See Also

dbhasretstat

dbrpcinit

dbnextrow

dbrpcparam

dbresults

dbrpcsend

dbretdata