Updating individual rows

int64_t key;

// ...

auto accounts_rs=accounts::create(conn);
accounts_rs->search("account_id", "=", key);

auto a=accounts->only();

std::cout << "Previous code: " << a->code.value() << std::endl;


The row objects for each resultset class, classname::base::row have a member for each column listed in the schema. Each member implement value() and isnull(), returning the value of that column in the row.

value(v) sets a new value of the column, and update() executes an SQL UPDATE statement that updates all modified columns. If no columns were modified, update() does nothing. The above example executes SQL equivalent to UPDATE accounts SET code='Acct6' where account_id=key.

Pass a nullptr to value() to SET the column to an SQL NULL, for those columns that are nullable.