need example for Triggers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • donilourdu
    New Member
    • Jan 2007
    • 53

    need example for Triggers

    hi I am doni

    I need example for tigger in MySQL database.

    looking for replies

    with regards,
    doni
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    In assume you do not mean TIGGERS but TRIGGERS?
    What have you done to get the info from the standard MySQL documentation?T hat shows samples. See Triggers

    You also do not specify for what situation you'd need it. Do we have to guess?

    Ronald :cool:

    Comment

    • donilourdu
      New Member
      • Jan 2007
      • 53

      #3
      Originally posted by ronverdonk
      In assume you do not mean TIGGERS but TRIGGERS?
      What have you done to get the info from the standard MySQL documentation?T hat shows samples. See Triggers

      You also do not specify for what situation you'd need it. Do we have to guess?

      Ronald :cool:
      thank you for reply
      well Ronald I already know that site. But It cant be clear for me. Could you give me a simple example

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Okay, this is a simple example.
        Assume: each time a row is inserted in table MyTable you want to log that event by adding a row to LogTable.
        Code:
        CREATE TRIGGER logit AFTER INSERT ON MyTable
        FOR EACH ROW 
        BEGIN
          INSERT INTO LogTable (timestamp, message)
          VALUES(NOW(), 'row added to MyTable');
        END;
        A good article with samples is shown at the OnLamp site at MySQL Triggers tryout

        Ronald :cool:

        Comment

        • donilourdu
          New Member
          • Jan 2007
          • 53

          #5
          [thank you Very much Ronald for your example.
          It realy helpful for me.

          with regards,
          Doni

          Originally posted by ronverdonk
          Okay, this is a simple example.
          Assume: each time a row is inserted in table MyTable you want to log that event by adding a row to LogTable.
          Code:
          CREATE TRIGGER logit AFTER INSERT ON MyTable
          FOR EACH ROW 
          BEGIN
            INSERT INTO LogTable (timestamp, message)
            VALUES(NOW(), 'row added to MyTable');
          END;
          A good article with samples is shown at the OnLamp site at MySQL Triggers tryout

          Ronald :cool:

          Comment

          Working...