Skip Headers
Oracle® Objects for OLE Developer's Guide
11g Release 2 (11.2) for Microsoft Windows

Part Number E12245-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

MovePreviousn, MoveNextn, MoveRel, and MoveTo Methods

Applies To

OraDynaset Object

Description

Change the cursor position to the specified row within the specified dynaset.

Usage

oradynaset.MovePreviousn offset
oradynaset.MoveNextn offset
oradynaset.MoveRel offset 
oradynaset.MoveTo offset

MoveNextn Method

Moves offset records forward.

MovePreviousn Method

Moves offset records backward.

MoveRel Method

Moves offset records relative to the current row. A positive value, represented by a plus (+) sign, moves the cursor down the table, and a negative value moves the cursor up the table.

MoveTo Method

Moves directly to row number offset.

Remarks

EOF is set when the cursor moves beyond the end of a dynaset using MoveNextn, MoveRel, or MoveTo methods. BOF is set when the cursor moves beyond the start of a dynaset using MovePreviousn, MoveRel, or MoveTo methods. The MoveNextn, MovePreviousn, and MoveTo methods accept offset as a positive integer only. The MoveRel methods accepts offset as either a positive or a negative integer.

The MoveTo rownum always gets the same row unless the row has been deleted. If the requested row has been deleted, the MoveTo method moves to the next valid row. The MoveNextn, MovePreviousn, MoveRel, and MoveTo methods do not take into account deleted rows, so be cautious when using these methods based on relative positions of row numbers.

Data Type

Long Integer

Examples

This example demonstrates the use of the MovePreviousn, MoveNextn, MoveRel, and MoveTo methods. Copy and paste this code into the definition section of a form. Then, press F5.

Private Sub Form_Load()
  Dim OraSession As OraSession 
  Dim OraDatabase As OraDatabase 
  Dim OraDynaset As OraDynaset 
  Dim OraFields As OraFields 
 
  Set OraSession = CreateObject("OracleInProcServer.XOraSession")
  Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "SCOTT/TIGER", 0&)
  Set OraDynaset = OraDatabase.CreateDynaset("select * from emp where empno" & _
             ">=7654 and empno <= 7844 ", ORADYN_NO LANKSTRIP)
  Set OraFields = OraDynaset.Fields 
 
  'Move to 3rd record from the first record
  OraDynaset.MoveNextn 3  'Should set EOF to true
  MsgBox OraFields("ename").Value  ' Should be display SCOTT
  
  If OraDynaset.EOF = True Then
    MsgBox "End of the record reached"
  End If
  
  'Move back from the current record by the offset 2
  OraDynaset.MovePreviousn 2    
  MsgBox OraFields("ename").Value  ' Should be display BLAKE
 
  If OraDynaset.BOF = True Then
    MsgBox "Start of the record reached"
  End If
   
  'Move relative in the forward direction 
  OraDynaset.MoveRel 2
  MsgBox OraFields("ename").Value  ' Should be display SCOTT
 
  If OraDynaset.EOF = True Then
    MsgBox "End of the record reached"
  End If
 
  'Move relative in the backward direction 
  OraDynaset.MoveRel -2
  MsgBox OraFields("ename").Value  ' Should be display BLAKE
 
  If OraDynaset.BOF = True Then
    MsgBox "Start of the record reached"
  End If 
 
  'Move to the record position 4 in the current dynaset
   OraDynaset.MoveTo 4
   MsgBox OraFields("ename").Value  ' Should be display SCOTT
  
End Sub