ALTER TYPE to add more methods and attributes : Alter Type « Object Oriented Database « Oracle PL / SQL






ALTER TYPE to add more methods and attributes

 
SQL>
SQL> CREATE OR REPLACE TYPE Dummy AS OBJECT (
  2    f1 NUMBER,
  3    f2 NUMBER,
  4    MEMBER PROCEDURE Method1(x IN VARCHAR2),
  5    MEMBER FUNCTION Method2 RETURN DATE
  6  );
  7  /

Type created.

SQL>
SQL> CREATE OR REPLACE TYPE BODY Dummy AS
  2    MEMBER PROCEDURE Method1(x IN VARCHAR2) IS
  3    BEGIN
  4      NULL;
  5    END Method1;
  6
  7    MEMBER FUNCTION Method2 RETURN DATE IS
  8    BEGIN
  9      RETURN SYSDATE;
 10    END Method2;
 11  END;
 12  /

Type body created.

SQL>
SQL> COLUMN object_name FORMAT a20
SQL>
SQL> SELECT object_name, object_type, status
  2    FROM user_objects
  3    WHERE object_name = 'DUMMY';

OBJECT_NAME          OBJECT_TYPE         STATUS
-------------------- ------------------- -------
DUMMY                TYPE                VALID
DUMMY                TYPE BODY           VALID

SQL>
SQL> ALTER TYPE Dummy REPLACE AS OBJECT (
  2    f1 NUMBER,
  3    f2 NUMBER,
  4    MEMBER PROCEDURE Method1(x IN VARCHAR2),
  5    MEMBER FUNCTION Method2 RETURN DATE,
  6    MEMBER PROCEDURE Method3
  7  );

Type altered.

SQL>
SQL>
SQL> SELECT object_name, object_type, status
  2    FROM user_objects
  3    WHERE object_name = 'DUMMY';

OBJECT_NAME          OBJECT_TYPE         STATUS
-------------------- ------------------- -------
DUMMY                TYPE                VALID
DUMMY                TYPE BODY           INVALID

SQL>
SQL>

 








Related examples in the same category

1.Alter user-defined type to add a new attribute
2.Alter a user-defined type