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: Inserting an OraObject

The following examples insert a new field (value instance) called "ADDRESS" in the server. 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 OraObject/OraRef.

Dynaset Example

Dim OraSession as OraSession

Dim OraDatabase as OraDatabase

Dim OraDynaset as OraDynaset

Dim AddressNew 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 person_tab

set OraDynaset = OraDatabase.CreateDynaset("select * from person_tab", 0&)

' create a new Address object in OO4O

set AddressNew = OraDatabase.CreateOraObject("ADDRESS")

'initialize the Address object attribute to new value

AddressNew.Street = "Oracle Parkway"

AddressNew.State = "CA"

'start the dynaset AddNew operation and set the Address field to new address

' value

OraDynaset.Addnew

OraDynaset.Fields("ADDR").Value = AddressNew

OraDynaset.Update

OraParameter Example

Dim OraSession as OraSession

Dim OraDatabase as OraDatabase

Dim OraDynaset as OraDynaset

Dim AddressNew 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 an OraParameter object represent Address object bind Variable

OraDatabase.Parameters.Add "ADDRESS", Null, ORAPARM_INPUT, ORATYPE_OBJECT, "ADDRESS"

' create a new Address object in OO4O

set AddressNew = OraDatabase.CreateObject("ADDRESS")

'initialize the Address object attribute to new value

AddressNew.Street = "Oracle Parkway"

AddressNew.State = "CA"

'set the Address to ADDRESS parameter

Oradatabase.Parameters("ADDRESS").Value = AddressNew

'execute the sql statement which updates Address in the person_tab

OraDatabase.ExecuteSQL ("insert into person_tab values (30,'Eric',:ADDRESS))


 
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