Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION trigf1()
- RETURNS trigger AS
- $$
- BEGIN
- IF EXISTS (SELECT *
- FROM sells join receipt on sells.license=receipt.license
- WHERE iname = new.iname and new.cid = receipt.cid and new.rno = receipt.rno
- ) THEN
- 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.
- ELSE
- RAISE NOTICE 'This Cafe Not selling %s item',new.iname;
- RETURN null;
- END IF;
- END;
- $$
- LANGUAGE 'plpgsql';
- CREATE or replace TRIGGER T1
- BEFORE INSERT
- ON buys
- FOR EACH ROW
- EXECUTE PROCEDURE trigf1();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement