Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create function max_open_orders() returns trigger as $max_open_orders$
- declare
- num_orders record;
- begin
- select into num_orders count(o_orderkey) as num from orders where o_orderstatus='O' group by o_custkey having o_custkey=NEW.o_custkey;
- if (num_orders.num = 18) then
- raise exception '% cannot have more than 18 open orders', NEW.custkey;
- end if;
- return null;
- end;
- $max_open_orders$ language plpgsql;
Add Comment
Please, Sign In to add comment