mysql multistatement query problem(if one query fail how we rollback) -



I am using MySQL c api for database interaction, I want to know if the MySQL multi statement If one query fails, then we roll back all the queries that are successfully executed .. .. ex-mysql_query (choose, select from "account_db *; choose account (*) from dbb; * select * from account_db *) - If there is a scenario there are questions dependent on each other and if one question fails then the other related The rear should be rollback to create database consistency, [mysql multi statement performs query one by one, we will examine all the questions, if all can run, then only continue the process]

Here in this example, the second query is incorrect, I want to, if any query fails then there should be no change in the database, is it possible?

now It has got a solution, I need to use the transaction here to read the transaction - gt; & Gt;
Then my query will look like- mysql_query (conn, "Start; select account_db; select number from account_dbb (*); choose account from _db; commit;)"

And where

mysql_query (conn, "commit");

mysql_query (conn, "rollback");

> Now if any query fails, all query updates will rollback .............

Comments