save value

I need to store a value in a grid.
this is my problem
sc_lookup (dataset, "SELECT SUM (planifica_pme4.monto_pme4) FROM planifica_pme4
INNER JOIN ON planifica_pme3 planifica_pme3.id_pme3 = planifica_pme4.id_pme3
WHERE planifica_pme4.id_pme3 = “{id_pme3}” ");
$ master_valor = {dataset [0] [0]};
{monto_pme3} = $ master_valor monto_pme3;

I need to save the result of the sum of the grid in the field planifica_pme4: monto_pme3 corresponding to the grid planifica_pme3.

what happens is that I put this code in the event of the grid onrecord planifica_pme3 and hands me the correct result in the field but do not save monto_pme3 need to do an update or something and how.
Please is of great importance

Re: save value

Hi,
you have to update your database yourself.
Using the " sc_exec_sql()" macro should be fine.

sc_exec_sql(“update yourtable set yourfield= {monto_pme3} where key = {your_key}”);

Re: save value

this is the update I need
sc_exec_sql ("UPDATE ON planifica_pme3 INNER JOIN planifica_pme4 planifica_pme4.id_pme3 = planifica_pme3.id_pme3
SET WHERE planifica_pme3.monto_pme3 = $ master_valor planifica_pme4.id_pme3 = ‘[id_pme3]’ ");

I think the php method and then call in the event on the grid onrecord planifica_pme4
but when I run the grid appears not only shows the buttons above

please if I can help

Re: save value

I think your update should more look like:

sc_exec_sql(“Update planifica.pme3 set monto_pm3 = $master_valor where planifica_pme3.id_mpe3=[id_mpe3]”);

Re: save value

when I put this method php

sc_lookup (dataset, "SELECT SUM (planifica_pme4.monto_pme4) FROM planifica_pme4
INNER JOIN ON planifica_pme3 planifica_pme3.id_pme3 = planifica_pme4.id_pme3
WHERE planifica_pme4.id_pme3 = [id_pme3] ");
$ master_valor = {dataset [0] [0]};
sc_master_value (‘monto_pme3’, $ master_valor);

sc_exec_sql (“UPDATE SET planifica_pme3 monto_pme3 = $ master_valor WHERE planifica_pme3.id_pme3 = [id_pme3]”);

in the event onrecord
blank grid appears only the information of the buttons above and I only want you to save me a value on the grid planifica_pme3 corresponding to the sum of values ​​of the grid planifica_pme4
please help is very important

Re: save value

I miss the table to update in your code !!

sc_exec_sql (“UPDATE TABLE-NAME SET planifica_pme3 monto_pme3 = $ master_valor WHERE planifica_pme3.id_pme3 = [id_pme3]”);

may be this is your problem !

Re: save value

OOOPS! Sorry, I had a typo in my last post.

Gerd is right, your code should be:
sc_exec_sql(“UPDATE planifica_pme3 SET monto_pm3 = $master_valor WHERE planifica_pme3.id_mpe3=[id_mpe3]”);

Re: save value

does not work to put this query in the event of the grid onrecord I get empty grid

sc_lookup(dataset, “SELECT SUM(planifica_pme4.monto_pme4) FROM planifica_pme4
INNER JOIN planifica_pme3 ON planifica_pme3.id_pme3=planifica_pme4.id_pme3
WHERE planifica_pme4.id_pme3=’[id_pme3]’”);
$master_valor = {dataset [0] [0] };
sc_master_value(‘monto_pme3’, $master_monto);

sc_exec_sql(“UPDATE planifica_pme3 SET planifica_pme3.monto_pme3= $master_valor WHERE planifica_pme4.id_pme3=’[id_pme3]’”);

I have two grids at the end of the grid and planifica_pme4 planifica_pme3
upon entry to the grid planifica_pme4 need to sum values ​​and the grid agrege planifica_pme3.
if someone could send me your email so please specify the problem better is very important

Re: save value

If I get it right you want to update your table “planifica_pme3” ?
It seems you still have a typo in your sql statement.
yours: sc_exec_sql(“UPDATE planifica_pme3 SET planifica_pme3.monto_pme3= $master_valor WHERE planifica_pme4.id_pme3=’[id_pme3]’”);
should be: sc_exec_sql(“UPDATE planifica_pme3 SET planifica_pme3.monto_pme3= $master_valor WHERE planifica_pme3.id_pme3=’[id_pme3]’”);

Re: save value

Agregas un campo nuevo tipo decimal y en el evento ONRECORD le dices:
sc_lookup (dataset, "SELECT SUM (planifica_pme4.monto_pme4) FROM planifica_pme4
INNER JOIN ON planifica_pme3 planifica_pme3.id_pme3 = planifica_pme4.id_pme3
WHERE planifica_pme4.id_pme3 = “{id_pme3}” ");
if (isset({rs[0][0]})) // Row found
{
{camponuevo} = {ds[0][0]}
}