i cant find right structure following question in pl/sql: need trigger on “products table” check price before inserting new product, product price must not exceed 4000$.
create or replace trigger pro before update of price on products each row declare pr products.price%type; begin if pr < 4000 insert products values (:old.product_id,:old.price); end if; end; please help
use check constraint instead of trigger:
create table products (price number); alter table products add constraint check_price check (price < 4000); test:
insert products values (5000) => error edit: if insist on trigger version:
create or replace trigger pro before insert or update of price on products each row begin if :new.price > 4000 raise_application_error(-20101, 'price exceeds 4000.'); end if; end;
Comments
Post a Comment