Re: Trying to Create a Trigger

2008-12-06 Thread Martijn Tonies
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. I'm surprised by the case sensitivity of OLD though, it works fine on

Re: Trying to Create a Trigger

2008-12-05 Thread David Giragosian
On 12/5/08, Lola J. Lee Beno [EMAIL PROTECTED] 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

Re: Trying to Create a Trigger

2008-12-05 Thread Lola J. Lee Beno
David Giragosian wrote: 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...? David No . . . 'old' is a virtual table that is the same as the table I'm doing work on. See

Re: Trying to Create a Trigger

2008-12-05 Thread Martijn Tonies
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

Re: Trying to Create a Trigger

2008-12-05 Thread Jim Lyons
can you not use referential integrity for this - assuming the tables are or can be made to be innodb? Does the jobposts table have a jobpost_id field, or is it just id? Maybe it's a typo? On Fri, Dec 5, 2008 at 11:28 AM, Lola J. Lee Beno [EMAIL PROTECTED] wrote: David Giragosian wrote:

Re: Trying to Create a Trigger

2008-12-05 Thread Lola J. Lee Beno
Jim Lyons wrote: can you not use referential integrity for this - assuming the tables are or can be made to be innodb? The tables are myISAM. These could be changed to innodb but I want to see if i can get this trigger work. Does the jobposts table have a jobpost_id field, or is it just

Re: Trying to Create a Trigger

2008-12-05 Thread Lola J. Lee Beno
Martijn Tonies wrote: What is the exact error message? Here's the latest query: 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

Re: Trying to Create a Trigger

2008-12-05 Thread Martijn Tonies
Hi, What is the exact error message? Here's the latest query: 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

Re: Trying to Create a Trigger

2008-12-05 Thread Lola J. Lee Beno
Martijn Tonies wrote: Hi, What is the exact error message? Here's the latest query: 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,

Re: Trying to Create a Trigger

2008-12-05 Thread Andy Shellam
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 =

Re: Trying to Create a Trigger

2008-12-05 Thread Lola J. Lee Beno
Andy Shellam wrote: 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. That's not it, unfortunately. ERROR: You have an error in your SQL syntax; check the manual

Re: Trying to Create a Trigger

2008-12-05 Thread Peter Brawley
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 'if @counted = 1 then SET dummy = 'Cannot delete this record' end if' at line 1 This works on 5.1.30 and 6.0.7: create table jobposts(adsource_id

Re: Trying to Create a Trigger

2008-12-05 Thread Martijn Tonies
Hi, What is the exact error message? Here's the latest query: 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

Re: Trying to Create a Trigger

2008-12-05 Thread Wm Mussatto
On Fri, December 5, 2008 12:14, Martijn Tonies wrote: Hi, What is the exact error message? Here's the latest query: delimiter // create trigger jobposts_control before delete on jobposts for each row begin declare dummy varchar(255); set @counted = ( select

Re: Trying to Create a Trigger

2008-12-05 Thread Andy Shellam
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