List:General Discussion« Previous MessageNext Message »
From:Andy Shellam Date:December 5 2008 11:37pm
Subject:Re: Trying to Create a Trigger
View as plain text  
> I think you are missing the point. Where is 'OLD' or 'old' defined? 
> Before you try to imbed it in a trigger, try the basic query.  That seems
> to be what its complaining about.
>
>   

OLD is a virtual table which is only present in a trigger - it's like a 
table with the same layout as the table the trigger is attached to, 
which contains the row (or rows) that were deleted (for a DELETE query) 
or updated (for an UPDATE query - pre-update.)  Just the same as (IIRC) 
NEW is a virtual table that contains the row (or rows) that were 
inserted (for an INSERT query) or updated (for an UPDATE query - 
post-update.)

The query in question will fail anywhere outside the trigger because NEW 
and OLD are only in scope in triggers.

OLD is akin to the "deleted" virtual table in MS SQL Server triggers, 
just like NEW is akin to the "inserted" virtual table in MSSQL.

Going back to the OP's problem - the original issue I believe was he was 
using "old" instead of "OLD" (case-sensitive) - now that's sorted, MySQL 
is complaining about a syntax error toward the end of the function 
declaration.

Andy
Thread
Trying to Create a TriggerLola J. Lee Beno5 Dec
  • Re: Trying to Create a TriggerDavid Giragosian5 Dec
    • Re: Trying to Create a TriggerLola J. Lee Beno5 Dec
      • Re: Trying to Create a TriggerJim Lyons5 Dec
        • Re: Trying to Create a TriggerLola J. Lee Beno5 Dec
  • Re: Trying to Create a TriggerMartijn Tonies5 Dec
    • Re: Trying to Create a TriggerLola J. Lee Beno5 Dec
  • Re: Trying to Create a TriggerMartijn Tonies5 Dec
    • Re: Trying to Create a TriggerLola J. Lee Beno5 Dec
      • Re: Trying to Create a TriggerAndy Shellam5 Dec
        • Re: Trying to Create a TriggerLola J. Lee Beno5 Dec
          • Re: Trying to Create a TriggerPeter Brawley5 Dec
  • Re: Trying to Create a TriggerMartijn Tonies5 Dec
    • Re: Trying to Create a TriggerWm Mussatto5 Dec
      • Re: Trying to Create a TriggerAndy Shellam6 Dec
  • Re: Trying to Create a TriggerMartijn Tonies6 Dec