Oracle Objects for OLE Release 9.2 Part Number A95895-01 |
|
Oracle object type member methods are created during type creation. Oracle object instance member methods are executed in OO4O as PL/SQL procedures or functions. Arguments and return values to the member methods should be bound using the OraParameter object. The first argument to the member method should always be the object instance. This object instance can be bound with the ORAPARM_INPUT or ORAPARM_BOTH mode. If the member method modifies the attributes of object instance and new object instance needs to be retrieved to the OO4O application, then this object instance must be bound with ORAPARM_BOTH mode.
For example, if we have a bank_account object type with member methods of open, close, and deposit methods. The schema for the bank_account is:
CREATE OR REPLACE TYPE bank_account AS OBJECT (
acct_number INTEGER(5),
balance REAL,
MEMBER PROCEDURE open (amount IN REAL),
MEMBER PROCEDURE close (num IN INTEGER, amount OUT REAL),
MEMBER PROCEDURE deposit (SELF IN OUT bank_bccount,num IN
INTEGER, amount IN REAL),
);
In OO4O, BankObj is an OraObject representing a valid bank object instance from the database. In order to execute the deposit method, the arguments SELF, num, and amount need to be bound using the OraParameter object
Dim BankObj as OraObject
assumes that we have valid BankObj
set BankObj = .....
create a OraParameter object for bank_account object and set it to BankObj
OraDatabase.Parameters.Add "BANK", BankObj, ORAPARM_BOTH,
ORATYPE_OBJECT, "BANK_ACCOUNT"
create a OraParameter object for num argument and set the value to 100
OraDatabase.Parameters.Add "ACCOUNT_NO", 100, ORAPARM_INPUT,
ORATYPE_NUMBER
create a OraParameter object for amount argument and set the value to 1200
OraDatabase.Parameters.Add "AMOUNT", 1200, ORAPARM_OUTPUT,
ORATYPE_NUMBER
display the balance from the bank object
Bankobj.balance
now execute the PL/SQL block for member method execution
OraDatabase.ExecuteSQL ("BEGIN BANK_ACCOUNT.DEPOSIT
(:BANK,:ACCOUNT_NO,:AMOUNT); END;")
get the modified bank object from the parameter
set Bankobj = OraDatabase.Parameters("BANK").Value
display the new balance
Bankobj.balance
|
Copyright © 1994, 2002 Oracle Corporation. All Rights Reserved. |
|