Guest User

Untitled

a guest
May 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. create function max_open_orders() returns trigger as $max_open_orders$
  2. declare
  3. num_orders record;
  4. begin
  5. 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;
  6. if (num_orders.num = 18) then
  7. raise exception '% cannot have more than 18 open orders', NEW.custkey;
  8. end if;
  9. return null;
  10. end;
  11. $max_open_orders$ language plpgsql;
Add Comment
Please, Sign In to add comment