<html>
<!-- BEGIN WEBMAIL STATIONERY -->
<head></head>
<body>
<!-- WEBMAIL STATIONERY noneset -->
<DIV></DIV>I've never used triggers before and I just started learning how to use stored procedures (since they were not available until MySQL 5 was released). I didn't know MS Access has stored procedures. See how little I know? You and the web application world have certainly moved somewhere ahead of me.<BR>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">-------------- Original message from <Daniel.Juliano@wellsfargo.com>: -------------- <BR><BR><BR>> To further what Dave is saying, if you ever code another page /app that <BR>> works with the same table(s), what are the chances you'll remember to <BR>> call all the stored procs you're relying on to enforce data integrity? <BR>> <BR>> You don't happen to come from an MS Access background, do you? Access <BR>> likes stored procs for select / insert / update /delete, but that's 1995 <BR>> methodology speaking, and the web application world has mostly since <BR>> moved on. <BR>> <BR>> =Dan <BR>> <BR>> -----Original Message----- <BR>> From: cialug-bounces@cialug.org [mailto:cialug-bounces@cialug.org] On <BR>> Behalf Of David Champion <BR>> Sent: Monday, October 23, 2006 12:01 PM <BR>> To: Central Iowa Linux Users Group <BR>> Subject: Re: [Cialu
g] mysql triggers -- figured them out <BR>> <BR>> Triggers always fire, but if you put these kinds of rules in a Stored <BR>> Procedure, they only fire when you call the SP. Example: if another web <BR>> page inserts a record or does an update without using the SP (say <BR>> another developer adds a page...) then your SP rules don't get applied. <BR>> <BR>> Using the Trigger, even if you just enter a record using phpMyAdmin, or <BR>> the mysql console, the rules will be enforced. <BR>> <BR>> -dc <BR>> <BR>> carl-olsen@mchsi.com wrote: <BR>> > I thought about checking into it for you, but I haven't really figured <BR>> out a reason to use triggers yet. I seem to be able to do the same <BR>> things using stored procedures, such as checking another table before <BR>> doing an insert, update or delete to see if a certain condition is true <BR>> or false. I like being able to do this stuff inside the database <BR>> instead of maki
ng a bunch of diffent PHP queries. It seems to take less <BR>> typing to do it all in a stored procedure. I'm glad you figured it out. <BR>> I bought a good book, if you're interested, "MySQL Store Procedure <BR>> Programming" by O'Reilly, ISBN 0-596-10089-2. It also has a chapter on <BR>> triggers. <BR>> > <BR>> > Carl Olsen <BR>> > http://www.carl-olsen.com/ <BR>> > <BR>> > <BR>> > -------------- Original message from "Kevin C. Smith" <BR>> > <KEVIN@LINUXSMITH.COM>: -------------- <BR>> > <BR>> > <BR>> > <BR>> >>Since I got no response I thought some might be interested in the <BR>> solution. <BR>> >>After reading the docs it turns out to be fairly simple. Yes, I didn't <BR>> <BR>> >>read the docs before; I was trying speed it up by getting pointed to <BR>> >>the TIMEDIFF function. To get the time difference of two fields using <BR>> >>a trigger. <BR>> >
;> <BR>> >>CREATE TRIGGER trigger_time BEFORE INSERT ON time_table FOR EACH ROW <BR>> >>SET NEW.time_diff = TIMEDIFF(NEW.end_time, NEW.begin_time); <BR>> >> <BR>> >>Of course an ON UPDATE trigger is also needed. <BR>> >> <BR>> >> <BR>> >>-- <BR>> >>Kevin C. Smith <BR>> >> <BR>> >>_______________________________________________ <BR>> >>Cialug mailing list <BR>> >>Cialug@cialug.org <BR>> >>http://cialug.org/mailman/listinfo/cialug <BR>> >> <BR>> >> <BR>> >>---------------------------------------------------------------------- <BR>> >>-- <BR>> >> <BR>> >>_______________________________________________ <BR>> >>Cialug mailing list <BR>> >>Cialug@cialug.org <BR>> >>http://cialug.org/mailman/listinfo/cialug <BR>> <BR>> <BR>> _______________________________________________ <BR>> C
ialug mailing list <BR>> Cialug@cialug.org <BR>> http://cialug.org/mailman/listinfo/cialug <BR>> <BR>> <BR>> _______________________________________________ <BR>> Cialug mailing list <BR>> Cialug@cialug.org <BR>> http://cialug.org/mailman/listinfo/cialug </BLOCKQUOTE>
<!-- END WEBMAIL STATIONERY -->
</body>
</html>