Oracle Objects for OLE
Release 9.2

Part Number A95895-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback

Example: OraCollection Iterator

The following example illustrates the use of an Oracle collection iterator .Before running the sample code, make sure that you have the necessary datatypes and tables in the database. See Schema Description used in examples of OraCollection.

Dim OraSession As OraSession

Dim OraDatabase As OraDatabase

Dim OraDynaset As OraDynaset

Dim CourseList As OraCollection

Dim Course As OraObject

'Create the OraSession Object.

Set OraSession = CreateObject("OracleInProcServer.XOraSession")

'Create the OraDatabase Object by opening a connection to Oracle.

Set OraDatabase = OraSession.OpenDatabase("ExampleDb",

"scott/tiger", 0&)

'Create a dynaset object from division

Set OraDynaset = OraDatabase.CreateDynaset("select courses from

division where name='History'", 0&)

'Retrieve a Courses column from Division.

Set CourseList = OraDynaset.Fields("Courses").Value

'Create the iterator

CourseList.CreateIterator

'Initialize the iterator to point to the beginning of a collection

CourseList.InitIterator

'Call IterNext to read CourseList until the end

While CourseList.EOC = False

Set Course = CourseList.ElementValue

course_no = Course.course_no

Title = Course.Title

Credits = Course.Credits

CourseList.IterNext

Wend

'Call IterPrev to read CourseList until the beginning

CourseList.IterPrev

While CourseList.BOC = False

Set Course = CourseList.ElementValue

course_no = Course.course_no

Title = Course.Title

Credits = Course.Credits

CourseList.IterPrev

Wend


 
Oracle
Copyright © 1994, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback