Search code examples
oracle-databasestored-proceduresplsqlpackageuser-defined-types

Oracle User defined type inside package definition


is it possible to have a User Defined Type inside Oracle package definition? When I try following

CREATE OR REPLACE PACKAGE AF_CONTRACT AS  -- spec
   -- PROCEDURE my_rpcedure (emp_id NUMBER);
   TYPE DTO_GRID AS OBJECT
   (
     ROWKEY    NVARCHAR2(200),
     COLUMNKEY NVARCHAR2(200),
     CELLVALUE NVARCHAR2(200),
     OLDVALUE  NVARCHAR2(200),
     TAG       NVARCHAR2(200)
   );
END AF_CONTRACT;
/
CREATE OR REPLACE PACKAGE BODY AF_CONTRACT AS  -- body

--   PROCEDURE my_procedure (emp_id NUMBER) IS
--   BEGIN
--      
--   END my_procedure;

END AF_CONTRACT;

I always get an error

Error: PLS-00540: object not supported in this context.

in the type definition.


Solution

  • Object types have to be declared at the database level. You could declare a collection type in a package specification.

    Possible duplicate of: Possible to create Oracle Database object types inside of PL/SQL?