[odb-users] mass update statement

Boris Kolpackov boris at codesynthesis.com
Fri Feb 3 08:49:34 EST 2012


Hi Sergey,

Ivanov Sergey <voicelessvoid at gmail.com> writes:

> Consider the following SQL query: "UPDATE table SET attr1 = 'abc' WHERE
> attr2 = 123".
> 
> Is there a way to perform this kind of mass updates without the use
> of database::execute method with plain-text sql? 

Not at the moment.


> Something similar to a database::erase_query could be nice.

When we were working on views we thought about extending the query
mechanism to also support DML statements. This will allow the kind
of things that you are looking for. The syntax could be along these
lines:

typedef odb::members<person> members;

db.update<person> (set (members::first = "John", members::last = "Doe"),
                   where (members::age < 18));

We could even support some more interesting cases:

db.update<person> (set (members::age = members::age + 1),
                   where (members::born == date::day_clock::local_day ()));

We have this feature on our TODO list. Hopefully we will get to it
soon. Thanks for the suggestion.

Boris



More information about the odb-users mailing list