Programming Guide



@dmengerrcode

Contains an engine-specific error code

Description

@dmengerrcode is set to 0 before executing a DBMS command. If the database engine detects an error, Panther writes the engine's error code to this variable. In cases where a database engine can generate multiple error codes for one statement, @dmengerrcode is an array, and each error code is written to a different occurrence.

A 0 (zero) value in this variable does not guarantee that the last statement executed without error. Some errors are detected by Panther's database driver before a request is made to the engine. For example, if an application attempts a SELECT before declaring a connection, Panther detects the error. Use the global variable @dmretcode to check for errors in Panther's database drivers.

Because the value of @dmengerrcode is engine-specific, it is strongly recommended that you install an error handler to test for these errors. In a multi-engine application, the error handler can call another function to do this depending on the engine.

If the default error 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. Refer to the Database Drivers for more information about the codes for a particular engine.

Example

proc dbi_errhandle (stmt, engine, flag)
if @dmengerrcode == 0
msg emsg @dmretmsg
else if engine == "xyzdb"
	call xyzerror (@dmengerrcode)
else if engine == "oracle"
call oraerror (@dmengerrcode)
else
msg emsg "Unknown engine."
return 1
proc xyzerror (error)
# Check for specific xyzdb error codes.
if error == 90931
msg emsg "Invalid user name."
else if error == ...
...
else
msg emsg @dmengerrmsg
return