Skip Headers
Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 2 (10.2)

Part Number B14308-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

GetServerErrorText Method

Applies To

OSession

ODatabase

Description

This method returns a text description of the most recent Oracle error in this session.

Usage

const char *GetServerErrorText(void) const

Remarks

This method returns the Oracle error message text for the most recent server error, if available. The error message contains an Oracle error number and may contain a brief description of the problem. Errors that occur while opening a database or in a transactional method will be reported on the session. Other errors are reported on the database.

The string returned is owned by the object. The caller should not free it; it will be freed when the object is destroyed, closed, the error is reset with ServerErrorReset, or another call is made to GetServerErrorText.

Return Value

A valid, null terminated const char pointer on success; NULL on failure.

Example

An example of a server error:

// open an ODatabase object

ODatabase odb("ExampleDB", "scott", "tiger");

if (! odb.IsOpen())

{ // Failed to open the database

OSession tempsess = odb.GetSession();

ErrorMessage(tempsess.GetServerErrorText());

}

// try to open a dynaset with a bad column name

ODynaset dyn(odb, "select xx from emp");

// if that didn't work, get the error message

if (!dyn.IsOpen())

{ // give the user a message box explaining the error

ErrorMessage(odb.GetServerErrorText());

}