André Silva
André Silva

Reputation: 1108

Oracle SQL Developer - expression is of wrong type

So I'm following this guide to avoid mutation errors since I used to query the table that fired the trigger and that obviously doesn't work. So I created this package as the guide clearly says.

CREATE OR REPLACE PACKAGE NOVOANOLECTIVO
AS

  TYPE ANOARRAY IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
  NOVOSTUPLOS ANOARRAY;
  VAZIO ANOARRAY;

END;

And the following trigger doesn't compile because it says "expression is of wrong type". But I'm just following the guide so what seems to be the problem ?

CREATE OR REPLACE TRIGGER T_AFTERANO 
AFTER INSERT OR UPDATE ON ANOLECTIVO
FOR EACH ROW

DECLARE

POSICAO INTEGER;

BEGIN
--APANHAR O CODIGO DOS NOVOS TUPLOS
  POSICAO := NOVOANOLECTIVO.NOVOSTUPLOS.COUNT + 1;

   NOVOANOLECTIVO.NOVOSTUPLOS(POSICAO) := :NEW.CODIGO;

END;

Upvotes: 0

Views: 193

Answers (1)

Jorge Campos
Jorge Campos

Reputation: 23361

As you said in the comments that the error is on this line NOVOANOLECTIVO.NOVOSTUPLOS(POSICAO) := :NEW.CODIGO; it means that the error is because you are putting the :new.codigo on NOVOSTUPLOS(POSICAO) which is a table of ROWID type and :new.codigo should be the same type of ROWID (whatever is this, I know it just in a query.) But it isn't.

Upvotes: 1

Related Questions