"ORA-04072: invalid trigger type" error. What is the problem?

Viewed 70
create or replace trigger "BILET_VANDUT"
for each row
AFTER insert on "AT_BILETE"
UPDATE AT_SPECTACOLE
SET s.NR_BILETE_VANDUTE= s.NR_BILETE_VANDUTE+1 FROM AT_SPECTACOLE s , AT_BILETE b WHERE s.ID_SPECTACOL=b.SPECTACOL;
 
end;
1 Answers

The immediate problem is that you have the clauses the worng way round; you start with:

create or replace trigger "BILET_VANDUT"
for each row
AFTER insert on "AT_BILETE"

but it should be

create or replace trigger "BILET_VANDUT"
AFTER insert on "AT_BILETE"
for each row
begin

(you were missing the PL/SQL begin as well, as @a_horse_with_no_name pointed out).

Your update is wrong too though; you can't update from something. You might just want:

UPDATE AT_SPECTACOLE
SET NR_BILETE_VANDUTE= NR_BILETE_VANDUTE+1;

You're going to run into consistency problems though when you can have multiple inserts at once, from different sessions. it's usually simpler to calculate those sorts of counts or totals when you need them, as part of a query, or with a view if you want to hide it a bit; and the view can be materialized if necessary.

Related