Oracle Objects for OLE
Release 9.0.1

Part Number A90173-01

Home

Book List

Contents

Master Index

Feedback

Retrieving a REF from the Database

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

Using a Dynaset Object

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

The following example selects an aperson column from the person table and a Person object is retrieved from the OraField object

set OO4OSession = CreateObject("OracleInProcServer.XOraSession")

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

set Customer = hrDb.CreateDynaset("select * from customers", 0&)

set Person = Customer.Fields("aperson").Value

Using a OraParameter object

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

The following lines of code explains using object datatype as bind variable in PLSQL anonymous block. This block selects object column from the database. This code uses a REF 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 "PERSON", Null, ORAPARM_OUTPUT,

ORATYPE_REF,"PERSONOBJ"

'execute the sql statement which selects Address from the person_tab

hrDb.ExecuteSQL ("BEGIN select aperson into :PERSON from customers

where account = 10; end;")

'retrieve Person object from the OraParameter

set Person = hrDb.Parameters("PERSON").Value


 
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.

Home

Book List

Contents