help pls

Pete pete at mollysrevenge.com
Wed Mar 14 13:25:20 EDT 2012


Hi Marek,
I have to admit I'm not fully understanding the requirement you described
on the forum but if you need to have a calculated value column based on
other columns, you can have the database do that by defining a triggers
that will happen every time an INSERT or UPDATE is done to the table in
question.  That way, the db does all the work for you and all you have to
do is a simple SELECT for the calculated column.

The syntax for creating a mySQL trigger is at
http://dev.mysql.com/doc/refman/5.5/en/create-trigger.html.  It would look
something like:

CREATE TRIGGER mytrigger AFTER INSERT ON thetable FOR EACH ROW
   UPDATE thetable SET PRICE to (NEW.Col1 * New.Col2) WHERE id=NEW.id

You would also have a second trigger defined as AFTER UPDATE.

With those triggers in place, just SELECT PRICE FROM theTable.

Hope that helps.

Pete

On Wed, Mar 14, 2012 at 9:30 AM, Marek Reichenbach <
reichenbach.marek at gmail.com> wrote:

> Hi , any suggestions on this post ?
> http://forums.runrev.com/viewtopic.php?f=12&t=11360&p=53356#p53356
> Help please
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list