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

</body>
</html>