Skip Headers

Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 1 (10.1)

Part Number B10119-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

MoveToMark Method

Applies To

ODynaset

Description

This method sets the current record to the record indicated by the ODynasetMark mark.

Usage

oresult MoveToMark(const ODynasetMark &mark)

Arguments

mark
An ODynasetMark previously returned by GetMark or GetLastModifiedMark
Remarks

An ODynasetMark is a way to remember a particular row and be able to get back to it quickly. An ODynasetMark is returned by the two ODynaset methods GetMark and GetLastModifiedMark.

The mark being used must have come from an ODynaset that is a handle on the same dynaset object, or a clone of that dynaset object.

Navigating to a marked record skips over any intervening records. Execution of this method sends OADVISE_MOVE_TOMARK messages to all attached advisories. One of the advisories could cancel the move, which would result in an OFAILURE return.

If the dynaset is being managed by an OBinder object, this method causes PreMove and PostMove triggers to be called. It is legal to call MoveToMark on the dynaset that an OBinder is managing.

Return Value

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

Example

This example uses a clone to figure out where to jump to in a dynaset. If you have a dynaset that has some overhead for moving (for example, one that has many advisories or is being managed by an OBinder), it may be faster to navigate around in a clone.

// open a database

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

// open a dynaset

ODynaset empdyn(odb, "select * from emp");

double salary; // the employee's salary

int mgrid; // the employee's manager's id

// get the employee's salary

empdyn.GetFieldValue("sal", &salary);

if (salary < 1000.0)

{ // this employee is underpaid - let's take care of that

// who is responsible for this?

empdyn.GetFieldValue("manager", &mgrid);

// let's go find that scoundrel

ODynaset tempdyn = empdyn.Clone(); // clone the employees

OField id = tempdyn.GetField("id"); // for speed

tempdyn.MoveFirst();

while (!tempdyn.IsEOF())

{

if (mgrid == (int) id)

break; // we found the manager

tempdyn.MoveNext();

}

// either we found the manager or...

if (tempdyn.IsEOF())

return; // we won't deal with this in an example

// a mark on the manager

ODynasetMark managerMark = tempdyn.GetMark();

// a mark on the employee

ODynasetMark empMark = empdyn.GetMark();

// now penalize that manager

empdyn.MoveToMark(managerMark); // go to manager record

empdyn.StartEdit(); // we're going to change things here

empdyn.SetFieldValue("sal", 700.0);

empdyn.Update();

// and give the employee a raise

empdyn.MoveToMark(empMark); // go to employee record

empdyn.StartEdit();

empdyn.SetFieldValue("sal", 7000.0);

empdyn.Update();

// Now everybody is happy. Go process some more.

}