Hi, I've been reading a lot and searching in the forums but I just can't get to a solution, so I'm needing some help, this is the deal...
I need to UPDATE 4 rows at the same time in the same table, I know this can be achieved by using 4 "Save Data" functions in the submit event, but, while this would work, it would create some consistency problems later, so It would be MUCH better to find a "one function" solution, furthermore the value to UPDATE in each row is only one, based on (WHERE) 'user_id' and 'field_id' (which could be one of four options: 1, 2, 3, 4)
Beats me, any ideas?
I need to UPDATE 4 rows at the same time in the same table, I know this can be achieved by using 4 "Save Data" functions in the submit event, but, while this would work, it would create some consistency problems later, so It would be MUCH better to find a "one function" solution, furthermore the value to UPDATE in each row is only one, based on (WHERE) 'user_id' and 'field_id' (which could be one of four options: 1, 2, 3, 4)
Beats me, any ideas?
Hi Zyraj,
You can use a "Loop event" function and inside it a "Save data" function, you will need to set the "data providers" correctly for this to work.
Best regards,
Max
You can use a "Loop event" function and inside it a "Save data" function, you will need to set the "data providers" correctly for this to work.
Best regards,
Max
Hi Max, thanks for your answer!!
But the four options being 1, 2, 3, 4 was random, lets say they are cat, dog, goat and bee, the DB was designed this way by someone else and I can't modify it at this point, any ideas?
But the four options being 1, 2, 3, 4 was random, lets say they are cat, dog, goat and bee, the DB was designed this way by someone else and I can't modify it at this point, any ideas?
Hi Zyraj,
This does not matter, your "Loop" data provider should point to the variable holding the 4 options, then your "save data" inside the loop can use the {var:loop_name.row} in the update syntax.
Best regards,
Max
This does not matter, your "Loop" data provider should point to the variable holding the 4 options, then your "save data" inside the loop can use the {var:loop_name.row} in the update syntax.
Best regards,
Max
Hi again!! Just realized about something, on one hand the data provider holds a lot of information besides the variables (I know this could be fixed), and on the other hand the loop would trigger 4 success events, I actually need this event to proceed with the next operations, that's the whole point of using one single function, so this would be a problem...
Hi Zyraj,
You want to run some action between 1 to 4 times, then you need a loop, and if you want to abort any of the 4 updates then do that in the "save data" update conditions, if the condition is not met then no update will occur
Best regards,
Max
You want to run some action between 1 to 4 times, then you need a loop, and if you want to abort any of the 4 updates then do that in the "save data" update conditions, if the condition is not met then no update will occur
Best regards,
Max
Hi Max, thanks again for your answer, but the point is not that I need to abort, but I need to combine the 4 UPDATEs into 1 operation, to me the loop is exactly the same as placing one after the other, and I even have more control of the functions that way, I guess there's no way around, anyway thanks for your help!!!
On another topic that's bugging me if I may ask right here... is there a way to set "ON DUPLICATE KEY UPDATE" on the INSERT query?
Chris
On another topic that's bugging me if I may ask right here... is there a way to set "ON DUPLICATE KEY UPDATE" on the INSERT query?
Chris
Hi Zyraj,
You need to update 4 rows with 1 update statement ? if this can be done using normal SQL then it will work using a single "Save data" call, otherwise you need a loop.
You can not use "on duplicate key update" feature, at least for now, you will need a custom SQL statement for this, but I have added it to the todo list.
Best regards,
Max
You need to update 4 rows with 1 update statement ? if this can be done using normal SQL then it will work using a single "Save data" call, otherwise you need a loop.
You can not use "on duplicate key update" feature, at least for now, you will need a custom SQL statement for this, but I have added it to the todo list.
Best regards,
Max
This topic is locked and no more replies can be posted.