[Cialug] mysql triggers -- figured them out
carl-olsen at mchsi.com
carl-olsen at mchsi.com
Mon Oct 23 11:48:33 CDT 2006
I thought about checking into it for you, but I haven't really figured out a reason to use triggers yet. I seem to be able to do the same things using stored procedures, such as checking another table before doing an insert, update or delete to see if a certain condition is true or false. I like being able to do this stuff inside the database instead of making a bunch of diffent PHP queries. It seems to take less typing to do it all in a stored procedure. I'm glad you figured it out. I bought a good book, if you're interested, "MySQL Store Procedure Programming" by O'Reilly, ISBN 0-596-10089-2. It also has a chapter on triggers.
Carl Olsen
http://www.carl-olsen.com/
-------------- Original message from "Kevin C. Smith" <kevin at linuxsmith.com>: --------------
> Since I got no response I thought some might be interested in the solution.
> After reading the docs it turns out to be fairly simple. Yes, I didn't
> read the docs before; I was trying speed it up by getting pointed to
> the TIMEDIFF function. To get the time difference of two fields using a
> trigger.
>
> CREATE TRIGGER trigger_time BEFORE INSERT ON time_table FOR EACH ROW SET
> NEW.time_diff = TIMEDIFF(NEW.end_time, NEW.begin_time);
>
> Of course an ON UPDATE trigger is also needed.
>
>
> --
> Kevin C. Smith
>
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20061023/53c165ea/attachment.html
More information about the Cialug
mailing list