[odb-users] Update multiple rows with an Object and/or View

Lukas Obermann obermann.lukas at gmail.com
Mon Oct 9 01:17:22 EDT 2017


Hi Boris,

thank you for the info!

Any rough plan on when it will be implemented?
Also, is there also a date for the next official release?

Thanks,
Lukas

> Am 06.10.2017 um 18:12 schrieb Boris Kolpackov <boris at codesynthesis.com>:
> 
> Lukas Obermann <obermann.lukas at gmail.com> writes:
> 
>> I am migrating a query which looks like this:
>> UPDATE table SET some_value = 0 WHERE path = ‚something‘;
>> 
>> It can also be that there are multiple joins in there to determine
>> which ones to update, those are set at runtime.
>> 
>> I know I can do it without joins something like this:
>> db.execute(
>>        "UPDATE "+odb::object_traits<MyTable, odb::database_id::id_mysql>::table_name+
>>        " SET "+ MyTable::m_myValue+" = 0 WHERE "+MyTable::m_path+“ = ’something’“);
>> 
>> Can this be done directly with an object, similar to how delete works.
> 
> No, this is not yet supported, though this feature (we call it "mass
> update") is on the TODO list. So currently the two options are the
> manual statement as you have shown above or loading and updating
> one object at a time. While the latter will have worse performance,
> sometimes it could be an acceptable sacrifice to keep the code simple.
> 
> Boris




More information about the odb-users mailing list