Cursor.columns
returns the number of columns in a cursor, but Cursor.updateRow
returns a number indicating whether or not an error occurred.
The Cursor.columns
and Resultset.columns
methods return an actual numeric value. The following methods return a numeric value that indicates a status code:
Connection.beginTransaction
Connection.commitTransaction
Connection.execute
Connection.majorErrorCode
Connection.minorErrorCode
Connection.release
Connection.rollbackTransaction
Connection.SQLTable
Cursor.close
Cursor.deleteRow
Cursor.insertRow
Cursor.updateRow
database.beginTransaction
database.connect
database.commitTransaction
database.disconnect
database.execute
database.majorErrorCode
database.minorErrorCode
database.rollbackTransaction
database.SQLTable
database.storedProcArgs
DbPool.connect
DbPool.disconnect
DbPool.majorErrorCode
DbPool.minorErrorCode
DbPool.storedProcArgs
Resultset.close
Stproc.closeIf the numeric return value of a method indicates a status code, 0 indicates successful completion and a nonzero number indicates an error. If the status code is nonzero, you can use the
majorErrorCode
and majorErrorMessage
methods of the associated Connection
, database
, or DbPool
object to find out information about the error. In some cases, the minorErrorCode
and minorErrorMessage
methods provide additional information about the error. For information on the return values of these error methods, see "Error Methods" on page 381.
blob
global function returns an object. In addition, the following methods return an object:
Connection.cursorWhenever you create a cursor, result set, or stored procedure, you should check for both the existence of the created object and for a possible return code. You can use the
Connection.storedProc
database.cursor
database.storedProc
DbPool (constructor)
DbPool.connection
Stproc.resultSet
majorErrorCode
and majorErrorMessage
methods to examine an error.
For example, you might create a cursor and verify its correctness with code similar to the following:
// Create the Cursor object.
custs = connobj.cursor ("select id, name, city
from customer order by id");
// Before continuing, make sure a real cursor was returned
// and there was no database error.
if ( custs && (connobj.majorErrorCode() == 0) ) {
// Get the first row
custs.next();
// ... process the cursor rows ...
//Close the cursor
custs.close();
}
else
// ... handle the error condition ...
Connection.connectedWhen a method returns a Boolean value,
Cursor.next
database.connected
DbPool.connected
Resultset.next
true
usually indicates successful completion, whereas false
indicates some other condition. A return value of false
does not indicate an actual error; it may indicate a successful termination condition.
For example, Connection.connected
returns false
to indicate the Connection
object is not currently connected. This can mean that an error occurred when the Connection
object was created, or it can indicate that a previously used connection was intentionally disconnected. Neither of these is an error of the connected
method. If an error occurred when the connection was created, your code should catch the error with that method. If the connection was terminated, you can reconnect.
As a second example, Cursor.next
returns false
when you get to the end of the rows in the cursor. If the SELECT
statement used to create the Cursor
object finds the table but no rows match the conditions of the SELECT
statement, then an empty cursor is created. The first time you call the next
method for that cursor, it returns false
. Your code should anticipate this possibility.
Connection.majorErrorMessage
Connection.minorErrorMessage
Cursor.columnName
database.majorErrorMessage
database.minorErrorMessage
DbPool.majorErrorMessage
DbPool.minorErrorMessage
Resultset.columnName
Connection.release
Cursor.close
database.disconnect
DbPool.disconnect
Resulset.close
Connection
, DbPool
, and database
objects to access database error codes and messages. The methods are:
majorErrorMessage
: major error message returned by the database.minorErrorMessage
: secondary message returned by the database.majorErrorCode
: major error code returned by the database. This typically corresponds to the server's SQLCODE.minorErrorCode
: secondary error code returned by the database.NOTE: Calling another method ofAfter receiving an error message, your application may want to display a message to the user. Your message may include the string returned byConnection
,DbPool
, ordatabase
can reset the error codes and messages. To avoid losing error information, be sure to check these methods before proceeding.
majorErrorMessage
or minorErrorMessage
or the number returned by majorErrorCode
or minorErrorCode
. Additionally, you may want to process the string or number before displaying it.
In computing the string returned by majorErrorMessage
and minorErrorMessage
, LiveWire returns the database vendor string, with additional text prepended. For details on the returned text, see the descriptions of these methods in the Server-Side JavaScript Reference.
majorErrorCode
and majorErrorMessage
methods to determine the particular error.
Table 19.1 Status codes for LiveWire methods
Status Code | Explanation | Status Code |
Explanation
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
---|
Last Updated: 11/12/98 15:29:47