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

ServerErrorSQLPos Method

Applies To

ODatabase

Description

When an error occurs during parsing of a SQL statement, this method returns the position within the SQL statement where the error occurred.

Usage

int ServerErrorSQLPos(void) const;

Remarks

Whenever the server detects an error while parsing an SQL statement, for instance during ODatabase::ExecuteSQL or ODynaset::Open, the position within the SQL string where the error occurred is remembered and can be obtained using this method. The position is 0-based; the first character in the SQL statement is character 0. If no error has occurred, or no SQL statements have been parsed by this database or since the last call to ServerErrorReset, then -1 is returned.

Return Value

Returns the character position of the SQL parse error (0 based) or -1 if there was no error.

Example

An example of a SQL parse error:

// open an ODatabase object

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

// execute a bad SQL statement

odb.ExecuteSQL("xxzzz");

int sqlpos = odb.ServerErrorSQLPos();

// sqlpos will be 0

// execute another bad SQL statement

odb.ExecuteSQL("drop zzz");

// the zzz doesn't make sense

sqlpos = odb.ServerErrorSQLPos();

// sqlpos will be 5