I am creating a transaction where I want to update a user in one table and delete some data in another that belongs to that user. But only the first query is executed, not the second one. In the delete statement in the second query code
is a comma-separated std::string.
pqxx::connection c(connectionString);
try {
pqxx::work w(c);
pqxx::result r;
c.prepare("user", "update user set started = null, finished = null, task = $1 where id = $2");
r = w.prepared("user")(task)(email).exec();
c.prepare("belongings", "delete from belongings where id in " \
"(select id from info where code in ($1) and id = $2)");
r = w.prepared("belongings")(code)(id).exec();
w.commit();
}
I read this SO-thread that explain how to run multiple queries before commit(). So I must be making a mistake in the second delete statement but can't find the reason.