From: Martijn Tonies Date: March 11 2005 9:24am Subject: Re: Better option then polling ? List-Archive: http://lists.mysql.com/mysql/181150 Message-Id: <019201c5261c$2412f890$3802a8c0@martijnws> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello, > I am fairly new to mysql and have a strange request .... I am not sure > if "stored procedures" will solve this. > > I have a table in a database that is constantly being updated with new > information. I would like to be notified if certain information gets > committed. > > Lets say for example the table gets updated every time a login attempt > happens regardless if it is successful or not. > > So I want an app to watch the table for incorrect logins and if found to > send an e-mail. > > Now there are several problems with this ... first... there could be > hundreds of logins so we do not want the same app to spawn multiple > processes each notifying the same incorrect login attempt. > > I was thinking about a cron that would run every X minute searching any > newly added rows and keeping the last row id in a tmp file. > > Is there a better way ? Well, as far as I know, not with MySQL. But you might request it for 5.0 ... Database engines like InterBase, Firebird and Oracle have "event mechanisms". Clients can register interest in a particular event and whenever the database "fires" such an even, the client will be notified in an asynchronous manner. A trigger on your table could solve this problem then. Obviously, this is a much better way compared to polling. :-) But, as I said, as far as I know, MySQL doesn't support this (yet). With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server Upscene Productions http://www.upscene.com