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

MoveNextN, MovePrevN, MoveRel, MoveTo Methods

Applies to

ODynaset

OBinder

Description

These methods change the cursor position to the specified row within the specified dynaset.

Usage

oresult MovePrevN(long rows, oboolean gopast = TRUE); // go to previous record

oresult MoveNextN(long rows, oboolean gopast = TRUE); // go to next record - the most frequently used

oresult MoveRel(long rows, oboolean gopast = TRUE); // move relative to the current record

oresult MoveTo(long rownum, oboolean gopast = TRUE); // go to the specified record

Remarks

IsEOF() returns TRUE when cursor moves beyond the end of dynaset using MoveNextN, MoveRel, MoveTo method.

IsBOF() returns TRUE when cursor moves beyond the start of dynaset using MovePrevN, MoveRel, MoveTo method.

MoveNextN, MovePrevN, and MoveTo accept positive integers only. MoveRel accepts both positive and negative integers.

Return Value

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

Example

{

long dbopt = 0; //the default is either no option

// or the default set

long dynopt = 0; //ditto

char *pCharBuff = NULL;

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

// create and open a dynaset

ODynaset odyn;

odyn.Open(odb, "select * from emp where empno >= 7654 and

empno <= 7844 ");

OField enamefield = odyn.GetField("ename");

//Move to 3rd record from the first record

odyn.MoveNextN(3); // 'Should set EOF to true

enamefield.GetValue((const char **)&pCharBuff);

MessageBox(pCharBuff); // Should be display SCOTT

enamefield.GetValue((const char **)&pCharBuff);

MessageBox(pCharBuff); // Should be display SCOTT

if(odyn.IsEOF())

MessageBox("End of the record reached");

//Move back from the current record by the offset 2

odyn.MovePrevN(2);

enamefield.GetValue((const char **)&pCharBuff);

MessageBox(pCharBuff); // Should be display BLAKE

if(odyn.IsBOF())

MessageBox("Start of the record reached");

//Move relative in the forward direction

odyn.MoveRel(2);

enamefield.GetValue((const char **)&pCharBuff);

MessageBox(pCharBuff); // Should be display SCOTT

if(odyn.IsEOF())

MessageBox("End of the record reached");

//Move relative in the backward direction

odyn.MoveRel(-2);

enamefield.GetValue((const char **)&pCharBuff);

MessageBox(pCharBuff); // Should be display BLAKE

if(odyn.IsBOF())

MessageBox("Start of the record reached");

//Move to the record position 4 in the current dynaset

odyn.MoveTo(4);

enamefield.GetValue((const char **)&pCharBuff);

MessageBox(pCharBuff); //Should be display SCOTT

odyn.MovePrevN(10); // 'Should set EOF to true

if(odyn.IsBOF())

MessageBox("Start of the record reached");

odyn.MoveNextN(11); // 'Should set EOF to true

if(odyn.IsEOF())

MessageBox("End of the record reached");

}