List:General Discussion« Previous MessageNext Message »
From:Martijn Tonies Date:December 5 2008 5:34pm
Subject:Re: Trying to Create a Trigger
View as plain text  

> I'm trying to create a trigger (5.0.45) and I've read the documentation 
> at mysql.com.  I keep getting a syntax error, but can't figure out what 
> the error is.  Here's the trigger I'm trying to create:
> 
> delimiter //
> create trigger jobposts_control
>  before delete on jobposts for each row
> begin
>    declare dummy varchar(255);
>    set @counted = (
>        select count(ad.adsource_id)
>        from adsource ad, jobposts jp
>        where ad.adsource_id = jp.adsource_id
>        and old.jobpost_id = jp.jobpost_id
>    );
>    if @counted >= 1 then SET dummy = "Cannot delete this record" end if;
> end //
> delimiter ;
> 
> When I run the set query without the "and old.jobpost_id" line, it runs 
> correctly.  So the syntax problem is elsewhere, but where?

What is the exact error message?

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Free Database Workbench Lite for MySQL at www.upscene.com !

Database questions? Check the forum:
http://www.databasedevelopmentforum.com
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