Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Question ALTER TYPE
Hello,
I'm using Oracle8i, Release 8.1.5, SQL Plus Release 8.1.5
I have a question about ALTER TYPE.
I first created the object 'data_t' with one method. 'DESC data_t' then gave both the argument and the method.
Then I altered the type and added new methods, but the next 'DESC data_t' gave again only the original method.
My question is this: have I really altered the type of this object, and if
so,
why are the new methods not shown by the 'DESC data_t'statement?
The exact statements and their results are given below.
In addition, can someone tell me how closely Object Orientated Databases follow true OO?
For example, when I alter the methods in an object, such as my Address
object, does this then
automatically alter the methods in all instances of that object, in all the
tables or in
any other objects? Or do I have to do this myself?
Thanks for your help..
Agnes
SQL> CREATE or Replace TYPE data_t AS OBJECT
2 ( year NUMBER, 3 MEMBER FUNCTION prod(invent NUMBER) RETURN NUMBER 4 );
Type created.
SQL> CREATE or replace TYPE BODY data_t IS
2 MEMBER FUNCTION prod (invent NUMBER) RETURN NUMBER IS 3 BEGIN 4 RETURN (year + invent); 5 END prod; 6 END;
Type body created.
SQL> desc data_t
Name Null? Type ----------------------------------------------------- -------- ------------
------------------------
YEAR NUMBER
METHOD
Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- INVENT NUMBER IN SQL> ALTER TYPE data_t REPLACE AS OBJECT 2 ( year NUMBER, 3 MEMBER FUNCTION prod(invent NUMBER) RETURN NUMBER, 4 MEMBER FUNCTION qtr(der_qtr number) RETURN number 5 );
Type altered.
SQL> CREATE OR REPLACE TYPE BODY data_t IS 2 MEMBER FUNCTION prod (invent NUMBER) RETURN NUMBER IS 3 BEGIN
4 RETURN (year + invent); 5 END; 6 7 MEMBER FUNCTION qtr(der_qtr number) RETURN number is 8 BEGIN 9 RETURN (year + der_qtr ); 10 END; 11 END;
Type body created.
SQL> desc data_t
Name Null? Type ----------------------------------------------------- -------- ------------
------------------------
YEAR NUMBER
METHOD
Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- INVENT NUMBER INReceived on Thu Aug 26 1999 - 10:20:00 CDT