oracle对象关系-pls-00538错误和pls-00539错误

gr8qqesn  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(303)

类型定义:

CREATE TYPE INTERVENTO_TY AS OBJECT(
  Testo VARCHAR2(20),
  Timestmp DATE
) NOT FINAL;

CREATE TYPE COMMENTO_TY UNDER INTERVENTO_TY(
  Ordine VARCHAR2(20)
);

CREATE TYPE POST_TY UNDER INTERVENTO_TY(
  Titolo VARCHAR2(20),
  MEMBER PROCEDURE AddCom(Ordine VARCHAR2, Testo VARCHAR2, Timestmp Date)
);

CREATE TYPE AUTORE_TY AS OBJECT(
  Nome VARCHAR2(20),
  Cognome VARCHAR2(20),
  IdAutore INT
);

CREATE TYPE MEDIA_TY AS OBJECT(
  Tipo VARCHAR2(20),
  Nome VARCHAR2(20),
  IdMedia INT,
  Titolo VARCHAR2(20)
);

CREATE TYPE SCRIVE_INTERVENTO AS TABLE OF REF INTERVENTO_TY;
CREATE TYPE DI_AUTORE AS TABLE OF REF AUTORE_TY;
ALTER TYPE INTERVENTO_TY ADD ATTRIBUTE DI DI_AUTORE CASCADE;
ALTER TYPE AUTORE_TY ADD ATTRIBUTE SCRIVE SCRIVE_INTERVENTO CASCADE;
CREATE TYPE IN_INTERVENTO AS TABLE OF REF INTERVENTO_TY;
CREATE TYPE CONTIENE_MEDIA AS TABLE OF REF MEDIA_TY;
ALTER TYPE INTERVENTO_TY ADD ATTRIBUTE CONTIENE CONTIENE_MEDIA CASCADE;
ALTER TYPE MEDIA_TY ADD ATTRIBUTE IN_INT IN_INTERVENTO CASCADE;
CREATE TYPE COMMENTATO_POST AS TABLE OF REF COMMENTO_TY;
ALTER TYPE COMMENTO_TY ADD ATTRIBUTE A REF POST_TY CASCADE;
ALTER TYPE POST_TY ADD ATTRIBUTE COMMENTATO COMMENTATO_POST CASCADE;

CREATE TABLE AUTORE_TAB OF AUTORE_TY
NESTED TABLE SCRIVE STORE AS SCRIVE_NESTED;

CREATE TABLE INTERVENTO_TAB OF INTERVENTO_TY
NESTED TABLE DI STORE AS DI_NESTED
NESTED TABLE CONTIENE STORE AS CONTIENE_NESTED;

CREATE TABLE MEDIA_TAB OF MEDIA_TY
NESTED TABLE IN_INT STORE AS IN_INT_NESTED;

我正在尝试编写一个对象过程来创建 COMMENTO_TY ,将其添加到 COMMENTO_TAB table和table COMMENTATO 嵌套表 POST_TY ,但它给了我以下错误:

CREATE OR REPLACE TYPE BODY Post_ty AS 
MEMBER PROCEDURE addComm(commento VARCHAR2, ordine NUMBER, IdAut INTEGER) AS
  NuovoCommento REF Commento_ty;
BEGIN
  INSERT INTO Intervento_tab I
  VALUES(Commento_ty(commento, SYSTIMESTAMP, 
                     DI_AUTORE(
                               (SELECT REF(A) FROM AUTORE_TAB A WHERE IdAutore = IdAut)
                              ),
                     CONTIENE_MEDIA(),
                     ordine,
                     (SELECT TREAT(REF(I) AS REF POST_TY)
                     FROM INTERVENTO_TAB I
                     WHERE VALUE(I) IS OF (POST_TY) AND
                           I.TIMESTMP = SELF.TIMESTMP)))
  RETURNING REF(I) INTO NuovoCommento;

  INSERT INTO TABLE(SELECT TREAT(VALUE(I) AS POST_TY).COMMENTATO
                    FROM INTERVENTO_TAB I
                    WHERE VALUE(I) IS OF (POST_TY)
                          AND I.TIMESTMP = SELF.TIMESTMP) 
  VALUES(NuovoCommento);
END addComm;
END;
/
``` `PLS-00538: subprogram or cursor 'ADDCOM' is declared in an object type specification and must be defined in the object type body` 3号线 `PLS-00539: subprogram 'ADDCOMM' is declared in an object type body and must be defined in the object type specification` 在2号线
ni65a41a

ni65a41a1#

您有两个错误:

PLS-00538: subprogram or cursor 'ADDCOM' is declared in an object type specification and must be defined in the object type body

PLS-00539: subprogram 'ADDCOMM' is declared in an object type body and must be defined in the object type specification

注意一个人的拼写 ADDCOM 另一个是 ADDCOMM ; 您需要确保成员过程在规范和主体中具有相同的名称。

相关问题