Open asmwarrior opened 11 months ago
Is it possible to avoid the
for
loop, so that in the statement, I can directly add(use) the whole rows, such as:soci::statement stmt = (sql.prepare << "INSERT INTO testtable (id, name, age) VALUES (:id, :name, :age)", soci::use(rows));
No, that's not possible because bulk operations with custom types are currently not supported.
No, that's not possible because bulk operations with custom types are currently not supported.
OK, thanks for the help. So, my current implementation is the correct way(using the for
loop) to add the custom types.
From the document, I see some example has extra functions:
such as
// first insert
int a0 = 0;
// update reference
stmt.exchange(soci::use(a0));
stmt.define_and_bind();
stmt.execute(true);
stmt.bind_clean_up();
So, do I need to adding the define_and_bind
and bind_clean_up
in my for loop in my first post in this ticket?
No, that's not possible because bulk operations with custom types are currently not supported.
OK, thanks for the help. So, my current implementation is the correct way(using the
for
loop) to add the custom types.
Yes, it is.
From the document, I see some example has extra functions:
such as
// first insert int a0 = 0; // update reference stmt.exchange(soci::use(a0)); stmt.define_and_bind(); stmt.execute(true); stmt.bind_clean_up();
So, do I need to adding the
define_and_bind
andbind_clean_up
in my for loop in my first post in this ticket?
As far as I can see, your initial code looks fine already.
The example you're referring to is used in cases where the variable to be bound isn't necessarily available during statement creation. This isn't the case in your example, so there's no need to explicitly call define_and_bind
and bind_clean_up
.
No, that's not possible because bulk operations with custom types are currently not supported.
OK, thanks for the help. So, my current implementation is the correct way(using the
for
loop) to add the custom types.Yes, it is.
Thanks, and sorry a bit late response.
As far as I can see, your initial code looks fine already. The example you're referring to is used in cases where the variable to be bound isn't necessarily available during statement creation. This isn't the case in your example, so there's no need to explicitly call
define_and_bind
andbind_clean_up
.
OK, thanks.
About the bulk operations for custom types, I see a pull request here: add support of bulk operations for ORM in ORACLE and SQLite backends #1053
Will this feature be discussed and merged in the future?
Hi, I would like to build operation on a table by adding many rows to a table, here is a simple code which looks OK
The person class has such definition:
My question is: is my code the best way to bulk operation of adding several rows from a vector?
Is it possible to avoid the
for
loop, so that in the statement, I can directly add(use) the whole rows, such as:Any ideas?
Thanks.