Oracle Objects for OLE C++ Class Library
Release 9.0.1

Part Number A90172-01

Home

Book List

Contents

Master Index

Feedback

StartEdit Method

Applies To

ODynaset

Description

This method begins the process of editing the current record.

Usage

oresult StartEdit(void)

Remarks

Editing an existing record in a dynaset consists of three steps:

  1. Call StartEdit.

  2. Change field values, either with SetFieldValue or SetValue.

  3. Call Update.

Calling StartEdit informs the ODynaset that you are going to edit the values of the current record. The ODynaset attempts to obtain a lock on the record from the Oracle database so that no other user can edit the record at the same time. The precise behavior depends on the database ODATABASE_EDIT_NOWAIT option (see ODatabase).

Once a lock is obtained the values of the record's fields in the database are compared to the what the dynaset thinks the values are (with the exception of long fields). If there is a difference it is assumed that some other user has changed the data in the database since the dynaset fetched the record. If a difference is found StartEdit will fail with an OERROR_DATACHANGE error.

This can be misleading. Consider a table where some of the records have default values set in the database or whose values are set by database triggers. When the records of such a table are updated to the database (after being added or edited by the dynaset) the values of some records may change in the database. If we then execute StartEdit on this we will fail with OERROR_DATACHANGE because the database values do not match the dynaset's values. To avoid this problem use the ODATABASE_ORAMODE option on the database (see ODatabase). With this option turned on the dynaset will refetch the record after the database has had a chance to change it.

Note: A call to StartEdit, AddNewRecord, DuplicateRecord, or DeleteRecord, will cancel any outstanding StartEdit, AddNewRecord or DuplicateRecord calls before proceeding. Any outstanding changes not saved using Update will be lost during the cancellation.

If the current query for the database resulted in a nonupdatable dynaset, this method fails.

Return Value

An oresult indicating whether the operation succeeded (OSUCCESS) or not (OFAILURE).

Example

This example sets the salary in the current record to $9985.

// we have a dynaset named empdyn

// edit the salary

empdyn.StartEdit();

empdyn.SetFieldValue("sal", 9985.0);

empdyn.Update();


 
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.

Home

Book List

Contents