You are missing a BEGIN in the trigger
delimiter |
CREATE TRIGGER greylist AFTER INSERT on greylist
BEGIN
delete from greylist where first_seen < NOW()-60*60*24*5;
END;
|
delimiter ;
Phil
On Wed, Nov 4, 2009 at 2:28 PM, Stefan Onken <support@stripped> wrote:
> Hello,
>
> I am new to using triggers in mysql. I am using mysql 5.1.37 and 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 | Type | Null | Key | Default |
> +---------------+---------------+------+-----+---------+
> | id | int(11) | NO | PRI | NULL |
> | SenderIP | varchar(15) | NO | MUL | NULL |
> | SenderAddress | varchar(1024) | NO | MUL | NULL |
> | first_seen | int(11) | NO | | NULL |
> +---------------+---------------+------+-----+---------+
> 4 rows in set (0,00 sec)
>
> I would like to archive that after every insert in the greylist table I am
> 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: http://lists.mysql.com/mysql?unsub=1
>
>
--
Distributed Computing stats
http://stats.free-dc.org