Reputation: 9
I am using Oracle Apex 5 trying to make a trigger that triggers when a record is added. It should prevent the party size being less than 1 and bigger than 6.
here is my code
create or replace trigger PARTYSIZE_CHECK
before
insert or update of PARTYSIZE
on BOOKING
for each row
begin
if (:new.PARTYSIZE<1 or :new.PARTYSIZE>6)
then raise_application_error(-20601,
'Party Size of ' || :new.PARTYSIZE || ' is too high, must be between 1 and 6. ';
end if;
end;
When I run the code in SQL commands, I receive the following error:
ORA-24344: success with compilation error.
Anyone know what the problem is?
Upvotes: 0
Views: 327
Reputation: 142798
I know, it is almost a 2-years old discussion.
However, trigger is probably not a solution one should choose - CHECK constraint seems to be more appropriate in this case. Something like
CREATE TABLE booking
(partysize INTEGER CONSTRAINT ch_party CHECK (partysize BETWEEN 1 AND 6));
Upvotes: 1
Reputation: 22949
You are missing the right parenthesis in call to raise_application_error
Upvotes: 2