mrbdrm
August 21, 2018, 10:55pm
1
I have a server action. in that server action i have this in this order:
1- database connection
2- database query
3- database update
my question how can i use the result of the database query in the database update? the data bindings doesn’t let me choose the output value of a spesifc column. only the whole query like so {{database Query}}
brad
August 21, 2018, 11:05pm
2
Have you created a GET variable in your action?
mrbdrm
August 21, 2018, 11:07pm
3
For? i have one to get the id i want to update.
brad
August 21, 2018, 11:08pm
4
That is the variable I mention. So that part is working for you? You get the proper values in your update form?
I’m not sure I quite understand what you are trying to do?
mrbdrm
August 21, 2018, 11:10pm
5
i thought i make it simple by the list
i want to calculate the total using mysql SUM then update other table with that total.
mrbdrm
August 22, 2018, 1:08am
6
I was able to do it.
but sadly its not possible with the data binding view. you have to type it.
to anyone want to do this:
in the query you want to get the result from (sum, avg, etc…). set up your query like so:(you can add as many columns as you want)
select SUM(price) AS totals FROM detail WHERE.....
now on the insert or update step after that we set up. you simple type this in the field you want to hold the sum value:
{{Query[0].totals.toNumber()}}
George
August 22, 2018, 5:44am
7
Of course you can do it in a single server action, there is a special action step called “repeat” for this.
So you can do something like this:
database connection
database query
repeat through the query
for each record do database update
but if all this is only for calculating a SUM - you can just select the SUM as field aggregate in the database query and you are done!
1 Like
mrbdrm
August 22, 2018, 11:41am
8
i never asked how to update multiple records or how to calculate the totals.
How can you access the result of a query from server side? that’s the question
George
August 22, 2018, 11:47am
9
Well easy - just use the server side data picker on the places where expression can be entered
mrbdrm
August 22, 2018, 11:49am
10
can you please show a screen shot selecting the result of a sum in server side?
George
August 22, 2018, 11:55am
11
How do you wan to use it? In a different step (what kind) or as output?
mrbdrm
August 22, 2018, 11:57am
12
in a different step
calculate the sum total
then update a table with that total
mrbdrm
August 22, 2018, 12:16pm
14
thats great
but if i only have one record will my solution be ok?
George
August 22, 2018, 12:17pm
15
Yes sure - it is pretty much the same
mrbdrm
August 22, 2018, 12:18pm
16
nice
i will mark your replay as answer then since its better
1 Like