List:General Discussion« Previous MessageNext Message »
From:Andy Shellam Date:December 5 2008 6:37pm
Subject:Re: Trying to Create a Trigger
View as plain text  
>
> 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;
>
>
> Now I just have this error message:
>
> ERROR: You have an error in your SQL syntax; check the manual
> that corresponds to your MySQL server version for the right
> syntax to use near 'end //
> delimiter' at line 1
>
> Query = end
> //
> delimiter
>

I'm guessing it's the first semi-colon in your IF statement.  Does this 
work...?

   if @counted >= 1 then SET dummy = 'Cannot delete this record' end if;

Just a guess!

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