Advice or best practice for updating multiple rows with a single query

2023-08-28 Thread Ritter
Dear Mongers, here is my example code trying to update multiple rows with a single query. Since the number of lines to be updated varies constantly, both the placeholders and the data need to be generated dynamically with each call. Based on the following example

Re: Advice or best practice for updating multiple rows with a single query

2023-08-28 Thread Peter J. Holzer
On 2023-08-28 08:57:51 +0200, Ritter wrote: > here is my example code trying to update multiple rows with a single > query. Since the number of lines to be updated varies constantly, both > the placeholders and the data need to be generated dynamically with > each call. > > Based on the

Re: Advice or best practice for updating multiple rows with a single query

2023-08-28 Thread Peter Meszaros
Hi, Another opportunity is to use execute_array() instead of execute(). Fore details search for 'execute_array' in 'perldoc DBI'. I use Postgresql in the example below, because I have no MySQL. sub db_update_with_fw_obj_ids { my $data = shift; my (@cust_id, @fw_id); for (values