Alfredo Salzillo
Alfredo Salzillo

Reputation: 142

Oracle Statement Ignored error

i've been stuck with this error for a while, could you help me with this? This's the code i'm trying to run:

CREATE OR REPLACE TRIGGER set_gal_trig 
      BEFORE INSERT ON MEDIA_CONTENUTI 
      FOR EACH ROW
DECLARE
       tipo_coll VARCHAR2(15);
       user2 VARCHAR2(30);
       user1 VARCHAR2(30);
BEGIN
     SELECT C.Tipo INTO tipo_coll FROM Collezione C WHERE :new.Cod_Collezione =     C.Cod_Collezione;
     SELECT C.Nome_Utente INTO user1 FROM Collezione C WHERE :new.Cod_Collezione = C.Cod_Collezione;
     SELECT M.Nome_Utente INTO user2 FROM Media M WHERE :new.Cod_Media = M.Cod_Media;
     IF (tipo = 'SET' AND user1 <> user2)
        THEN
        Raise_application_error(-20075, 'Inserimento non valido, un SET puo contenere solo media appartenenti al proprietario');
     ELSIF (tipo = 'GALLERIA' AND user1= user2)
        THEN
        Raise_application_error(-20076, 'Inserimento non valido, una GALLERIA puo contenere solo media non appartenenti al proprietario');
     END IF;
END;

The error is: Error at line 9: PL/SQL: Statement ignored. Thanks for the help!

Upvotes: 0

Views: 65

Answers (1)

Alex Poole
Alex Poole

Reputation: 191570

Without the full error stack, the obvious error is in line 9 as the top-level error message says (where line numbers are counted only within the PL/SQL part of the statement, not the first three non-PL/SQL lines):

 IF (tipo = 'SET' AND user1 <> user2)

You don't have a variable called tipo, so this should be:

 IF (tipo_coll = 'SET' AND user1 <> user2)
  ...
 ELSIF (tipo_coll = 'GALLERIA' AND user1= user2)

Upvotes: 2

Related Questions