Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 1 (10.1) Part Number B10119-01 |
|
Applies To
Description
This method deletes the current record from the dynaset result set.
Usage
oresult DeleteRecord(void)
Remarks
This method deletes the current record from the dynaset. Execution of this method sends OADVISE_DELETE messages to all attached advisories. It is not necessary to call StartEdit or Update to delete a record.
After the record has been deleted, the current record will not be valid (it has been deleted). If the deletion was from a dynaset, you must navigate yourself to a valid record. The OBinder class will attempt to move to an adjacent valid record by itself.
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.
OBinder calls the PreDelete and PostDelete triggers when this method is called.
Note that once you call Delete on a given row in a dynaset in a global transaction (that is once you issue a BeginTrans), locks will remain on the selected rows until you call commit the transaction or rollback.
Return Value
An oresult indicating whether the operation succeeded (OSUCCESS) or not (OFAILURE).
Example
This example deletes all managers.
// open the database
ODatabase odb("ExampleDB", "scott", "tiger");
// open a dynaset on the employee table
ODynaset empdyn(odb, "select * from emp");
// get an OField object for looking at the job field
OField job = empdyn.GetField("job");
// look through all the employees
while (!empdyn.IsEOF())
{
if (0 == strcmp((const char *) job, "MANAGER"))
{ // we found a manager; delete that employee
empdyn.DeleteRecord();
}
// go to next record (gets us to valid record)
// or past EOF if there are no more records
empdyn.MoveNext();
}