Alex Zabiela
Alex Zabiela

Reputation: 9

Error with trigger on Oracle apex 5

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

Answers (2)

Littlefoot
Littlefoot

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

Aleksej
Aleksej

Reputation: 22949

You are missing the right parenthesis in call to raise_application_error

Upvotes: 2

Related Questions