Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email email@example.com
From: David Giragosian (dgiragosiangmail.com)
Date: Fri Dec 05 2008 - 11:18:50 CST
On 12/5/08, Lola J. Lee Beno <lolahis.com> wrote:
> 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
> 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?
I'm no expert, but 'old' is a table, I'm guessing, and it isn't referenced
in the 'from' clause of the query.
could it be that simple...?