OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Trying to Create a Trigger

From: Andy Shellam (andy-listsnetworkmail.eu)
Date: Fri Dec 05 2008 - 12:37:37 CST


>
> 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.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql