Advertisement
ncamaa1

Untitled

Aug 7th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE FUNCTION trigf1()
  2.   RETURNS trigger AS
  3. $$
  4. BEGIN
  5.     IF EXISTS (SELECT *
  6.         FROM sells join receipt on sells.license=receipt.license
  7.          WHERE iname = new.iname and new.cid = receipt.cid and new.rno = receipt.rno
  8.         ) THEN
  9. RETURN new; -- checks if item iname is equal to the insert item and if in table sells license equal to the license in table receipt.
  10.     ELSE
  11. RAISE NOTICE 'This Cafe Not selling %s item',new.iname;
  12. RETURN null;
  13. END IF;
  14. END;
  15. $$
  16. LANGUAGE 'plpgsql';
  17.  
  18. CREATE or replace TRIGGER T1
  19. BEFORE INSERT
  20. ON buys
  21. FOR EACH ROW
  22. EXECUTE PROCEDURE trigf1();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement