1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

How to write after insert event update trigger on the same table in mysql 5.0

Discussion in 'MySQL Forums' started by haraprasad, Jun 19, 2009.

  1. haraprasad

    haraprasad Active Member

    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    80
    DELIMITER |
    Create trigger trg_airlines_insert
    before insert on airlines
    for each row
    begin
    IF NEW.transactionid != 0 THEN
    Update airlines SET new.HABWno = '1';
    end if;
    end |
    DELIMITER ;
    The above trigger i have written on airlines table.
    When i am inserting a new transactionid to airlines table,its not updating HABWno column in the same table.
    What is the reason and how to fix it.
     
  2. oliviathomas

    oliviathomas Active Member

    Messages:
    13
    Likes Received:
    1
    Trophy Points:
    90
    Location:
    london
    mysql> delimiter //
    mysql> CREATE TRIGGER upd_check BEFORE UPDATE ON account
    -> FOR EACH ROW
    -> BEGIN
    -> IF NEW.amount < 0 THEN
    -> SET NEW.amount = 0;
    -> ELSEIF NEW.amount > 100 THEN
    -> SET NEW.amount = 100;
    -> END IF;
    -> END;//
    mysql> delimiter ;