Home » SQL & PL/SQL » SQL & PL/SQL » Object type
Object type [message #37781] Thu, 28 February 2002 01:28 Go to next message
roberto
Messages: 10
Registered: February 2002
Junior Member
This is my object:
TYPE Bank_Account AS OBJECT (
acct_number INTEGER(5),
balance REAL,
status VARCHAR2(10),
MEMBER PROCEDURE open (amount IN REAL),
MEMBER PROCEDURE verify_acct (num IN INTEGER),
MEMBER PROCEDURE close (num IN INTEGER, amount OUT REAL),
MEMBER PROCEDURE deposit (num IN INTEGER, amount IN REAL),
MEMBER PROCEDURE withdraw (num IN INTEGER, amount IN REAL),
MEMBER FUNCTION curr_bal (SELF IN OUT Bank_Account,num IN INTEGER) RETURN REAL
);
---
TYPE BODY Bank_Account AS
MEMBER PROCEDURE verify_acct (num IN INTEGER) IS
-- check for wrong account number or closed account
BEGIN
IF (num <> acct_number) THEN
RAISE_APPLICATION_ERROR(-20105, 'wrong number');
ELSIF (status = 'closed') THEN
RAISE_APPLICATION_ERROR(-20106, 'account closed');
END IF;
END verify_acct;

MEMBER FUNCTION curr_bal (SELF IN OUT Bank_Account, num IN INTEGER) RETURN REAL IS
BEGIN
verify_acct(num);
RETURN balance;
END curr_bal;
END;
---
from sql plus...

declare
a bank_account;
b real;
begin
a:=bank_account(1,1,'xx');
b:=a.curr_bal(a,1);
end;
declare
*
ERROR at line 1:
ORA-06550: line 7, column 4:
PLS-00306: wrong number or types of arguments in call to 'CURR_BAL'
ORA-06550: line 7, column 1:
PL/SQL: Statement ignored

which is the error?
Re: Object type [message #37785 is a reply to message #37781] Thu, 28 February 2002 03:20 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
hi,

instead of
b:=a.curr_bal(a,1);
use
b:=a.curr_bal(1);
-----------
declare
a bank_account;
b real;
begin
a:=bank_account(1,1,'xx');
b:=a.curr_bal(1);
end;
--------
cheers
pratap
Re: Object type [message #37788 is a reply to message #37781] Thu, 28 February 2002 03:58 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
Member functions, by default, pass the self parameter as an IN parameter.

when you try to change the value of the object within the function or u want to call the member procedure , then u have specify IN OUT
Previous Topic: ASP n PL/SQL
Next Topic: Trusted Oracle
Goto Forum:
  


Current Time: Fri Apr 26 22:39:52 CDT 2024