This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Procedure Example CREATE PROCEDURE PRC_PROD_DISCOUNT LANGUAGE SQL BEGIN UPDATE PRODUCT SET P_DISCOUNT = P_DISCOUNT + .05 WHERE P_ONHAND >= P_MIN*2; END CALL PRC_PROD_DISCOUNT; update product p1 set p_discount = (select p_discount from ch06_SALESCO.PRODUCT P2 WHERE P1.P_CODE = P2.P_CODE); Triggers drop trigger TRG_PROD_REORDER; drop trigger TRG_PROD_REORDER2; CREATE TRIGGER TRG_PROD_REORDER BEFORE INSERT ON PRODUCT REFERENCING NEW AS N FOR EACH ROW IF (N.P_ONHAND <= N.P_MIN) THEN SET N.P_REORDER = 1; ELSE SET N.P_REORDER = 0; END IF CREATE TRIGGER TRG_PROD_REORDER2 BEFORE update of p_onhand, p_min ON PRODUCT REFERENCING NEW AS N FOR EACH ROW IF (N.P_ONHAND <= N.P_MIN) THEN SET N.P_REORDER = 1; ELSE SET N.P_REORDER = 0;...
View Full Document
- Spring '07