MySQL Forums
Forum List  »  Connector/C++

Re: Prepared Statements - Incorrect behaviour
Posted by: Ulf Wendel
Date: July 19, 2010 11:27AM

I don't see any bug in your code, but it sounds strange. We have pretty similar code in one of the examples and it works just fine.

num_rows = 0;
prep_stmt.reset(con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)"));
for (i = 0; i < EXAMPLE_NUM_TEST_ROWS; i++) {
prep_stmt->setInt(1, test_data.id);
prep_stmt->setString(2, test_data.label);
/* executeUpdate() returns the number of affected = inserted rows */
num_rows += prep_stmt->executeUpdate();
}


If I where you, I'd switch to INSERT for the very moment. One can easily get confused about what is in the DB and what gets changed when using UPDATE. No idea but the suggestion to look into that.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Prepared Statements - Incorrect behaviour
1356
July 19, 2010 11:27AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.