Reputation: 57
Using the Vertx SQL Client API (https://vertx.io/docs/vertx-jdbc-client/java/#_using_the_sql_client_api) how can I execute an update and get the number or rows updated to tell me if the update was a success.
I used LAST_INSERTED_ID for inserts, but what about updates and deletes?
return db.client.preparedQuery(
"DELETE FROM table WHERE id = ?")
.execute(Tuple.of(id))
.map(rs -> rs.property(MySQLClient.?????)
);
Thanks!
Upvotes: 0
Views: 665
Reputation: 9138
The number of affected rows should be given by the SqlResult.rowCount()
method:
db.client.preparedQuery("DELETE FROM table WHERE id = ?")
.execute(Tuple.of(id))
.map(res -> {
int count = res.rowCount());
return count;
})
);
Upvotes: 2