Oracle® Objects for OLE Developer's Guide 11g Release 2 (11.2) for Microsoft Windows Part Number E17727-03 |
|
|
PDF · Mobi · ePub |
Creates a value instance or referenceable object in the cache and returns the associated OO4O object.
OraObject1 = OraDatabase.CreateOraObject(schema_name) OraRef1 = OraDatabase.CreateOraObject(schema_name,table_name) OraCollection1 = OraDatabase.CreateOraObject(schema_name)
The arguments for the method are:
Arguments | Description |
---|---|
OraObject1 |
A valid OraObject object representing a newly created value instance. |
OraRef1 |
A valid OraRef object representing a newly created referenceable object. |
OraCollection |
A valid OraCollection object representing a newly created collection instance. |
schema_name |
A String specifying the schema name of the value instance to be created. |
table_name |
A String specifying the table name of the referenceable object to be created. |
If the table_name
argument is not specified, it creates a value instance in the client and returns an OraObject
or OraCollection
object. If the table_name
argument is specified, it creates a referenceable object in the database and returns an associated OraRef
object.
OraObject
and OraRef
object examples are provided. Before running the sample code, make sure that you have the necessary data types and tables in the database. See "Schema Objects Used in the OraObject and OraRef Examples".
Example: Creating an OraObject Object
The following example illustrates the use of the CreateOraObject
method to insert a value instance. The row containing ADDRESS
is inserted as a value instance in the database.
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)")
Example: Creating an OraRef Object
The following example illustrates the use of the CreateOraObject
method to insert referenceable objects.
In this example, a new PERSON
is inserted as a referenceable object in the database.
Dim OraSession as OraSession Dim OraDatabase as OraDatabase Dim Person as OraRef '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&) 'CreteOraObject creates a new referenceable 'object in the PERSON_TAB object table and returns associated OraRef set Person = OraDatabase.CreateOraObject("PERSON","PERSON_TAB") 'modify the attributes of Person Person.Name = "Eric" Person.Age = 35 'Update method inserts modified referenceable object in the PERSON_TAB. Person.Update