Modifying fetched rows

auto a1=conn->config_get_static_cursor_attributes1();
auto has_positioned_update=a1.count("SQL_CA1_POSITIONED_UPDATE");
auto has_positioned_delete=a1.count("SQL_CA1_POSITIONED_DELETE");

auto stmt=conn->create_newstatement("CURSOR_TYPE", "STATIC")
    ->execute("SELECT memo_id, memo_text FROM memos");

int memo_id;
std::string memo_text;

stmt->fetch("memo_id", memo_id, "memo_text", memo_text);

stmt->modify_fetched_row(0, "UPDATE memos SET memo_text=?", "New memo text");

modify_fetched_row() executes an SQL UPDATE or DELETE statement for one of the rows in a resultset. The first parameter is a 0-based row number, which is always zero with single row resultsets obtained from fetch(). Specify a 0-based row number to reference the appropriate row in a multi-result resultset from fetch_vectors() (which, sadly, may not work correctly). The second parameter is an UPDATE or DELETE statement, with the remaining parameters, if any, specifying any parameter values; any parameter value that's accepted by execute().

The SQL statement does not have a “WHERE” clause. It automatically affects only the specified row of the resultset. Not all database drivers implement positioned updates and deletes for all cursor types. Use the appropriate config() setting, config_get_forward_only_cursor_attributes1(), config_get_static_cursor_attributes1(), config_get_dynamic_cursor_attributes1(), or config_get_keyset_cursor_attributes1(); and check if the cursor supports the SQL_CA1_POSITIONED_UPDATE or SQL_CA1_POSITIONED_DELETE, respectively.