Hyderabad Jobs Book Website FREE PowerBuilder Training I Love Hyderabad Hyderabad Colleges
Home Business Emails Hyderabad Classifieds Contact Us
7 Wonders of Hyderabad Web Hosting Yellow Pages Our Network

 
Webpowerbuilder.hyderabad-colleges.com

Advanced PowerBuilder

HomePrevious Lesson: DELETE Trigger On trans Table
Next Lesson: An Introduction to Triggers

UPDATE Trigger On trans Table

CREATE trigger tran_upd_trig after update on trans
REFERENCING old AS old_tran new AS new_tran
FOR EACH ROW
BEGIN
   If "old_tran"."tran_type" = 'R' Or
      "old_tran"."tran_type" = 'T' Then
      Update "product_master"
         Set "product_master"."product_balance" =
             "product_master"."product_balance" -
             "old_tran"."tran_qty" + "new_tran"."tran_qty"
         Where "product_master"."product_no" = 
               "old_tran"."tran_item_no"
   Elseif "old_tran"."tran_type" = 'I' Then
      Update "product_master"
         Set "product_master"."product_balance" =
             "product_master"."product_balance" +
             "old_tran"."tran_qty" - "new_tran"."tran_qty"
         Where "product_master"."product_no" = 
               "old_tran"."tran_item_no"
   End If
END;

Now is the right time to close database painter and run the application and test it. Check if product_master is properly updated or not.
HomePrevious Lesson: DELETE Trigger On trans Table
Next Lesson: An Introduction to Triggers

Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com