Oracle
 sql >> Database >  >> RDS >> Oracle

Errori PLS-00539 e PLS-00538 durante la creazione di funzioni UDT

Ci sono alcuni errori che hai commesso durante la dichiarazione, vedi la spiegazione in linea:

CREATE OR REPLACE TYPE VC_MNumber AS OBJECT
(
   idno NUMBER,
   MEMBER FUNCTION dimension
      RETURN NUMBER,
   MEMBER FUNCTION typeName
      RETURN VARCHAR2
)
   NOT INSTANTIABLE NOT FINAL;
/

--DROP TYPE VC_MINTEGER;

CREATE OR REPLACE  TYPE VC_MInteger
   UNDER VC_MNumber
   (
      OVERRIDING MEMBER FUNCTION dimension
         RETURN NUMBER,
      OVERRIDING MEMBER FUNCTION typeName
         RETURN VARCHAR2
   );
/

CREATE OR REPLACE  TYPE VC_MReal
   UNDER VC_MNumber
   (
      YDCCoeff NUMBER,
      CbDCCoeff NUMBER,
      CrDCCoeff NUMBER,
      OVERRIDING MEMBER FUNCTION Dimension --<--Overriding function should have same name
         RETURN NUMBER,
      OVERRIDING MEMBER FUNCTION typeName
         RETURN VARCHAR2
   )
    FINAL;
/

CREATE OR REPLACE TYPE BODY VC_MReal
AS
   OVERRIDING MEMBER FUNCTION Dimension
      RETURN NUMBER
   IS
      var_dimension   NUMBER := 10;
   BEGIN
      RETURN var_dimension;
   END;

   OVERRIDING MEMBER FUNCTION typeName  --<-- You declared in Object type as `overriding` function and using it as `Member function` alone.
      RETURN VARCHAR2
   IS
      var_typeName   VARCHAR2 (400) := 'VC_MREAL';
   BEGIN
      RETURN var_typeName;
   END;
END;
/