Programming Guide



@dmretcode

Contains an engine-independent error or status code

Description

@dmretcode is set to 0 before Panther executes a new DBMS command. If the command fails because of an error detected either by the engine or by Panther's database driver, Panther writes an error code to @dmretcode describing the failure.

Usually a non-zero value in @dmretcode indicates that an error occurred. The default or an installed error handler is called for an error. If the default handler is in use, Panther displays the statement which failed and an error message from either Panther's database driver or from the database engine. If the application has installed its own error handler, the installed function controls what messages are displayed.

There are two non-zero codes for @dmretcode which are not errors: DM_NO_MORE_ROWS and DM_END_OF_PROC. When an engine indicates that it has returned all rows for a select set, Panther writes the DM_NO_MORE_ROWS code to @dmretcode. Since this is not considered an error, Panther does not call the default or installed error handler. You can test for DM_MORE_ROWS after executing a SELECT or in an exit handler.

Panther uses DM_END_OF_PROC with engines that support stored procedures. When an engine indicates that it has completed executing the stored procedure, Panther writes the DM_END_OF_PROC code to @dmretcode. This is not an error. An application can test for this code in an exit procedure or after calling a stored procedure. Refer to the Database Drivers for information on stored procedures.

The values for @dmretcode are listed alphabetically in Table 12-3 (in the source code, they reside in dmerror.h).

Table 12-3 @dmretcode error codes and corresponding messages

Code constant Message

DM_ABORTED

Processing aborted due to DB error.

DM_ALREADY_INIT

Engine already installed.

DM_ALREADY_ON

Already logged in.

DM_ARGS_NEEDED

Arguments required.

DM_BAD_ARGS

Bad arguments.

DM_BAD_CMD

Bad command.

DM_BIND_COUNT

Incorrect number of bind variables.

DM_BIND_VAR

Bad or missing bind variable.

DM_COMMIT

Commit failed.

DM_DESC_COL

Describe select column error.

DM_END_OF_PROC

End of procedure.

DM_FETCH

Error during fetch.

DM_INVALID_DATE

Invalid date.

DM_KEYWORD

Bad or missing keyword.

DM_LOGON_DENIED

Logon denied.

DM_MANY_CURSORS

Too many cursors.

DM_NO_CURSOR

Cursor does not exist.

DM_NO_MORE_ROWS

No more rows indicator.

DM_NO_NAME

No name specified.

DM_NO_TRANSACTION

Transaction does not exist.

DM_NOCONNECTION

No connection active.

DM_NODATABASE

No database selected.

DM_NOTLOGGEDON

Not logged in.

DM_NOTSUPPORTED

Command not supported for specified engine.

DM_PARSE_ERROR

SQL parse error.

DM_ROLLBACK

Rollback failed.

DM_TRAN_PEND

Transaction pending.

Example

proc entry
DBMS ONERROR JPL dbi_errhandle
DBMS ONEXIT JPL dbi_exithandle
...
return
proc dbi_errhandle (stmt, engine, flag)
# Check for logon errors.
if @dmretcode == DM_ALREADY_ON
return 0
else if @dmretcode == DM_LOGON_DENIED
msg emsg @dmretmsg "%N" @dmengerrmsg
....
return 1
proc dbi_exithandle (stmt, engine, flag)
if @dmretcode == DM_NO_MORE_ROWS
msg emsg "All rows returned."
return 0