From: Michael Dykman Date: November 4 2009 7:35pm Subject: Re: trigger List-Archive: http://lists.mysql.com/mysql/219247 Message-Id: <814b9a820911041135s7a528e3epc123906054d8e379@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Well you might need to parenthesize the expression, but note that simple integer math done on a DATE or DATETIME, the units are days. you probably want ... where first_seen < (NOW() - 5); michael dykman On Wed, Nov 4, 2009 at 2:28 PM, Stefan Onken wrote: > Hello, > > I am new to using triggers in mysql. I am using mysql 5.1.37 =A0and would= like > to setup a trigger like: > > CREATE TRIGGER greylist AFTER INSERT on greylist > delete from greylist where first_seen < NOW()-60*60*24*5; > END; > > When typing this into mysql I am getting an error. Where is my mistake? > > > mysql> show fields from greylist; > +---------------+---------------+------+-----+---------+ > | Field =A0 =A0 =A0 =A0 | Type =A0 =A0 =A0 =A0 =A0| Null | Key | Default = | > +---------------+---------------+------+-----+---------+ > | id =A0 =A0 =A0 =A0 =A0 =A0| int(11) =A0 =A0 =A0 | NO =A0 | PRI | NULL = =A0 =A0| > | SenderIP =A0 =A0 =A0| varchar(15) =A0 | NO =A0 | MUL | NULL =A0 =A0| > | SenderAddress | varchar(1024) | NO =A0 | MUL | NULL =A0 =A0| > | first_seen =A0 =A0| int(11) =A0 =A0 =A0 | NO =A0 | =A0 =A0 | NULL =A0 = =A0| > +---------------+---------------+------+-----+---------+ > 4 rows in set (0,00 sec) > > I would like to archive that after every insert in the greylist table I a= m > purging the oldest xx records. > > Stefan > > > > www.stonki.de : My, myself and I > www.kbarcode.net : barcode solution for KDE > www.krename.net : renamer for KDE > www.proftpd.de : a FTP server... > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: =A0 =A0http://lists.mysql.com/mysql?unsub=3Dmdykman@gmail= .com > > --=20 - michael dykman - mdykman@stripped "May you live every day of your life." Jonathan Swift