Re: help pls

2012-03-14 Thread Pete
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.ma...@gmail.com wrote:

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


Re: help pls

2012-03-14 Thread Marek Reichenbach
Hi Pete.
Thank you very much for the reply
I dont have to put data (no INSERT)... i meant something like thig

put SELECT isv_laik,atv_laik,atstum,(select kaina from tarifai use index
(tarifas) where (kg_nuo' sGalutine1 ' and ' sGalutine1 '=kg_iki)
and (km_nuoatstum and atstum=km_iki) as dynamicCol FROM reisas where
gal=' sResaultSave  'ORDER BY isv_laik into tSQL
put revDataFromQuery(tab, cr, sDatabaseID, tSQL) into tData

atstum - it must take different value ot atstum in every row from column
2... but in the end column 4 must show (select kaina...) , where kaina is
from the other table.

updated:
http://forums.runrev.com/viewtopic.php?f=12t=11360p=53370#p53370


On 14 March 2012 19:25, Pete p...@mollysrevenge.com wrote:

 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.ma...@gmail.com wrote:

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

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode