Hi,
I ve a below structured object TYPE in Oracle to calculate the Simple and Compound interest for an amount..
Code:
CREATE TYPE pnr_typ AS OBJECT
(
principle NUMBER,
interest NUMBER,
year NUMBER,
MEMBER FUNCTION si RETURN FLOAT,
MEMBER FUNCTION ci RETURN FLOAT,
MEMBER FUNCTION prod(invent NUMBER) RETURN NUMBER
);
/
show err
CREATE TYPE BODY pnr_typ IS
MEMBER FUNCTION si RETURN FLOAT IS
BEGIN
RETURN (principle*interest*SELF.year)/100;
END; MEMBER FUNCTION ci RETURN FLOAT IS
BEGIN
RETURN POWER(SELF.principle*(1 + SELF.interest/100), year);
END;
MEMBER FUNCTION prod (invent NUMBER) RETURN NUMBER IS
BEGIN
RETURN (year + invent);
END;
END;
/
Show err
With in the TYPE i define some attributes like
principle, interest, year and more member functions like
si, ci, prod to access and modify the TYPE attributes.
This TYPE can be used in
* the column definition while creating a column in a table,
* the procedures or Oracle DB objects as an instance
I would like to know if the
TYPE (structured) in DB2 can do the same as the above Oracle TYPE.
Thanks,
Sn