Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 2 (10.2) B14308-01 |
|
Applies To
Description
ODynasetMark constructor
Usage
ODynasetMark(void)
ODynasetMark(const ODynasetMark &othermark)
Arguments
othermark | another ODynasetMark object that you are copying |
These methods construct a new ODynasetMark instance.
The default constructor constructs an unopened ODynasetMark object. It cannot fail.
The copy constructor copies another ODynasetMark object. If that other ODynasetMark object is open - which means it contains a valid mark on a dynaset - that mark will be copied. The copy constructor can fail; check whether the new ODynasetMark is open after the constructor call.
There is no Open method for the ODynasetMark class. To get an open ODynasetMark, call either GetMark or GetLastModifiedMark.
Example
This example finds the employee with the lowest salary and then gives that person a big commission.
// open the employee database
ODatabase odb("ExampleDB", "scott", "tiger");
// open a dynaset on the employee's table
ODynaset odyn(odb, "select sal, comm from emp");
// the low employee mark
ODynasetMark lowmark; // default constructor. lowmark is not open
double lowsalary = 100000.;
// find the lowest salary
OField salf = odyn.GetField(0); // salary is the 0th field
odyn.MoveFirst();
while (!odyn.IsEOF())
{
if ((double) salf < lowsalary)
{ // the lowest we've seen yet
// get a mark. odyn.GetMark returns an open ODynasetMark
lowmark = odyn.GetMark();
lowsalary = (double) salf;
}
odyn.MoveNext();
}
if (lowmark.IsOpen())
{ // we found a lowest - give them a big commission
odyn.MoveToMark(lowmark);
odyn.StartEdit();
odyn.SetFieldValue("comm", 2000.0);
odyn.Update();
}