Results 1 to 6 of 6

Thread: triggle after and before problem

  1. #1
    Join Date
    Jul 2003
    Posts
    421

    triggle after and before problem

    I have triggle
    {code}
    CREATE TRIGGER myTrigger
    after DELETE ON Post
    FOR EACH ROW
    BEGIN
    INSERT into transaction_log(userId,UniversityN, EnglishName,ChineseName, AccessTime)
    select UserId, UniversityN,EnglishName, ChineseName, AccessTime from Post
    where (Date(Current_Date)-Date(AccessTime))>=8
    and UserId in( select UserId from ApplyStatus where ReceiveAll=false);

    END$$
    {/code}
    if I delete more then one rows on post table and use before on my triggle, I always get duplicate insert on my ransaction_log,
    if I use after in my triggle, I only get one row insert into ransaction_log
    how to deal with this problem??
    Thank y ou
    ________
    Nash Ambassador History
    Last edited by sql; 03-06-2011 at 02:09 AM.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    What do you need? Is it on sql server?

  3. #3
    Join Date
    Jul 2003
    Posts
    421
    i have store procedure
    {code}
    CREATE PROCEDURE dropStudent()
    BEGIN
    delete from Post
    where(Date(Current_Date)-Date(AccessTime))>=8
    {/code}
    and UserId in( select UserId from ApplyStatus where ReceiveAll=false);
    I want some information get insert into my transaction_log table
    ________
    OG KUSH
    Last edited by sql; 03-06-2011 at 02:09 AM.

  4. #4
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    sql server? oracle? sybase? informix? DB2?

  5. #5
    Join Date
    Jul 2003
    Posts
    421
    I use mysql 5.6
    ________
    Buy easy vape
    Last edited by sql; 03-06-2011 at 02:09 AM.

  6. #6
    Join Date
    Sep 2002
    Posts
    5,938
    Can you post some sample data? What to delete and what to log?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •