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

OnChangedError Method

Applies To

OBinder

Description

This method is called by OBinder when there is an error processing a changed message.

Usage

virtual void OnChangedError(void) const

Remarks

When an OBound subclass instance notifies its OBinder instance that it has changed its value (by calling OBound::Changed) the OBinder will call StartEdit on its dynaset. This may fail for a variety of reasons. The most common are that another user has a lock on the row, or the current user doesn't have permission to edit the row, or that the data in the database has changed. If the StartEdit call fails OBinder will call OnChangedError.

This routine is supplied separately because often the call sequence that causes the error is very indirect. For instance the OBound instance may change the value when an assignment operator is called, or when some user-interface widget is used. OnChangedError is a callback mechanism allowing your code to obtain control when an error has occurred.

OnChangedError is a virtual function. The implementation in OBinder saves the current server error number and class library error number. These are available using the routine OBinder::GetChangedError. You can subclass OBinder and override GetChangedError with your own error handling method. That overriding method should call OBinder::OnChangedError so that the OBinder will be able to obtain the server error numbers for use by GetChangedError.

Example

This example sets up a managed dynaset (OBinder) and shows changed error handling.

// construct the OBinder
OBinder empblock;

// here we have several OBoundVal objects (see the Workbook)
OBoundVal salary;
OBoundVal ename;

// bind the OBoundVal objects to the OBinder
salary.BindToBinder(&empblock, "sal");
ename.BindToBinder(&empblock, "ename");

// now open the OBinder
ODatabase odb("ExampleDB", "scott", "tiger");  // open the database
empblock.Open(odb, "select * from emp order by ename");

/*
At this point the OBinder and OBound subclass instances are all set up. The
first record of the dynaset is current. Now we can try to change a value.
*/

salary = 3499.99;
/*
That tried to initiate a database change. Note that there was no return value
for us to check for success. We need to call GetChangedError to find out if
that worked.
*/

long servererr;
long classerr;
if (empblock.GetChangedError(&servererr, &classerr))
{
    // error processing here
}