Oracle Objects for OLE Release 9.2 Part Number A95895-01 |
|
The following example illustrates the use of the CreateOraObject method to insert a value instance. 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.
In these examples, the row containing "ADDRESS" is inserted as a value instance in the server.
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.CreateOraObject("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
('Eric',30,:ADDRESS))
|
Copyright © 1994, 2002 Oracle Corporation. All Rights Reserved. |
|