Saturday, November 15, 2008

Object Types in PL/SQL

PL/SQL supports object-oriented programming through object types. An object type
encapsulates a data structure along with the functions and procedures needed to
manipulate the data.The variables that form the data structure are known as
attributes. The functions and procedures that manipulate the attributes are known as
methods.


CREATE TYPE bank_account AS OBJECT (
acct_number NUMBER(5),
balance NUMBER,
status VARCHAR2(10),
MEMBER PROCEDURE open (SELF IN OUT NOCOPY bank_account, amount IN NUMBER),
MEMBER PROCEDURE close (SELF IN OUT NOCOPY bank_account, num IN NUMBER,
amount OUT NUMBER),
MEMBER PROCEDURE deposit (SELF IN OUT NOCOPY bank_account, num IN NUMBER,
amount IN NUMBER),
MEMBER PROCEDURE withdraw (SELF IN OUT NOCOPY bank_account, num IN NUMBER,
amount IN NUMBER),
MEMBER FUNCTION curr_bal (num IN NUMBER) RETURN NUMBER );
/

No comments:

search engine

Custom Search