Skip Headers

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

Part Number B10118-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

Retrieving an Embedded/Value Instance from the Database

An OraObject object can be retrieved using OO4O in the following ways:

Using a Dynaset Object

If a table contains an object type column and a dynaset's query selects against that column, then the Value property of OraField object returns an OraObject.

The following code selects an ADDRESS column from the person table and then an 'Address' object is retrieved from the OraField object

set OO4OSession = CreateObject("OracleInProcServer.XOraSession")

set hrDb = OO4OSession.OpenDatabase("ExampleDb", "scott/tiger", 0)

set Person = hrDb.CreateDynaset("select * from person", 0&)

set Address = Person.Fields("Addr").Value

Using a Parameter Object

If a SQL statement or PL/SQL block has a bind variable of object type, you create a OraParameter object using the OraParameters Add method. The Value property of the OraParameter object for that bind variable returns an OraObject.

The following example uses an object datatype as a bind variable in a PLSQL anonymous block. This block selects an object column from the database.

set OO4OSession = CreateObject("OracleInProcServer.XOraSession")

set hrDb = OO4OSession.OpenDatabase("ExampleDb", "scott/tiger", 0)

hrDb.Parameters.Add "ADDRESS", Null, ORAPARM_OUTPUT, ORATYPE_OBJECT,

"ADDRESS"

'execute the sql statement which selects Address from the person_tab

hrDb.ExecuteSQL ("BEGIN select Addr into :ADDRESS from person where

age = 40; end;")

'retrieve Address object from the OraParameter

set address = hrDb.Parameters("ADDRESS").Value