//  Suppose the parameters sql There are more than one sql sentence . Such as sql = "insert into table1(...) values(...); update table2 set a=1;";

const bool CDBOperator::MultiQuery(const std::string sql, std::string& error)

{
int res = 0;
bool ret = false;
MYSQL_RES* result = NULL;
std::string e;
try
{
//disable autocommit
if(!AutoCommit(AUTOCOMMIT_DISABLE, error))
{
return false;
}
res = mysql_real_query(m_mysql, sql.c_str(), sql.length());
// if query fail
if(0 != res)
{
error = mysql_error(m_mysql);
Rollback(e);
AutoCommit(AUTOCOMMIT_ENABLE, e);
return false;
}
do
{
/* did current statement return data? */
result = mysql_store_result(m_mysql);
if (result) {
mysql_free_result(result);
} else { /* no result set or error */
if (mysql_field_count(m_mysql) == 0) {
printf("%lld rows affected\n",
mysql_affected_rows(m_mysql));
} else { /* some error occurred */
printf("Could not retrieve result set\n");
break;
}
}
/* more results? -1 = no, >0 = error, 0 = yes (keep looping) */
if ((res = mysql_next_result(m_mysql)) > 0)
printf("Could not execute statement\n");
} while (res == 0);
ret = Commit(error);
AutoCommit(AUTOCOMMIT_ENABLE, e);
if(!ret)
{
return false;
}
return true;
}
catch(...)
{
error = mysql_error(m_mysql);
return false;
}

mysql c connector multiple sql More articles on sentence execution examples

  1. One SQL What are the reasons for the statement's slow execution ?| MySQL Recommendations for high performance optimization specifications

    One SQL What are the reasons for the statement's slow execution https://mp.weixin.qq.com/s?__biz=Mzg2OTA0Njk0OA==&mid=2247485185&idx=1&am ...

  2. Tencent interview : One SQL What are the reasons for the statement's slow execution ?--- Don't look at regret series

    Tell the truth , This question can relate to MySQL A lot of core knowledge , You can pull out a lot of , It's like testing your knowledge of computer network , Ask you " Input URL After the return , What's going on " equally , See how much you can say . Before Tencent ...

  3. One SQL What are the reasons for the statement's slow execution ?

    Tell the truth , This question can relate to MySQL A lot of core knowledge , You can pull out a lot of , It's like testing your knowledge of computer network , Ask you “ Input URL After the return , What's going on ” equally , See how much you can say . The truth of Tencent's interview before , Also asked about this ...

  4. One SQL What are the reasons for the statement's slow execution ?( turn )

    One  SQL  Statement execution is slow , It's very slow every time ? Or is it normal in most cases , Sometimes it's very slow ? So I think , We also score the following two cases to discuss . 1. Most of the time it's normal , It's just that sometimes it's very slow . 2. In the data ...

  5. One SQL What are the reasons for the slow execution of statements

    One SQL Statement execution is slow , There are two situations : 1. Most of the time it's normal , Sometimes it's slow When the database is busy processing data , Update or new data will be temporarily recorded to redo log journal , Synchronize data to disk when idle . Suppose the database is busy all the time , Update again ...

  6. MySQL Of EXPLAIN The command is used for SQL Query execution plan of statement

    MySQL Of EXPLAIN The command is used for SQL Query execution plan of statement (QEP). The output of this command allows us to understand MySQL How does the optimizer execute SQL Of the statement . The order does not offer any adjustment advice , But it can provide important information ...

  7. mysql If there is sql Statement error , Will it cause an automatic rollback ?

    Business , We all know it's atomic , The operation is either all successful , All or nothing . But it can lead to misunderstandings . Let's prepare a table first , To test it CREATE TABLE `name` ( `id` int(11) unsigned ...

  8. sql Statement execution time

    Statistics mysql Every one of them SQL Statement execution time Collection CrazyHarry Published in  2 Years ago read  3785 Collection  8 give the thumbs-up  3 Comment on  3 Google.Github Dual certification front end course , Exclusive Silicon Valley content , Weekly live ...

  9. Jenkins In Engineering SQL The method of statement execution

    Preface A lot of online jenkins The project is based on shell Or batch call sql File execution sql The way of command , Most of them need to be based on sql Documents to complete , So in sql When a statement changes, you need to jenkins The server modifies the corresponding sq ...

Random recommendation

  1. redis Start in the background

    Yesterday in cmd Window start , The window closed , Another visit will report an error , So I opened it this time First you need to install the service :redis-server --service-install redis.windows.conf --loglevel ...

  2. Android The image processing

    Believe in doing Android The development of small partners for Android Picture compression . Cutting must be very impressive , Today I'm going to lead you to learn this mysterious knowledge , In order to study later . I can help you at work . First of all, let's look at the problem ...

  3. MEAN.JS introduction

    MEAN stands for: download :MongoDB Download the file Baidu disk sharing Run the command :mongod Remind you dbpath(/data/db/) does not exist, terminating gen ...

  4. LTS

    LTS(light-task-scheduler) It is mainly used to solve the distributed task scheduling problem , Support real-time tasks , Timed tasks and Cron Mission . Good scalability , Extensibility , Robust and stable and used by many companies . 1. Support distributed , More solutions ...

  5. How to BigDecimal convert to Int

    BigDecimal a=new BigDecimal(12.88); int b=a.intValue(); System.out.println(b);//b=12;

  6. With the SQL Server A network related or instance specific error while establishing a connection

    The customer has a problem , use “ Server name \ Instance name ” Remote connection to another named instance failed , newspaper “ With the SQL Server A network related or instance specific error while establishing a connection , Server not found or unreachable . Please verify that the instance name is correct ...

  7. [MSSQL2012]LEAD function

    LEAD The function is simple , Is to extract a column of data from the next row to the current row to display , It's better to see the examples , Let's look at the test script first DECLARE @TestData TABLE(     ID INT IDENTITY(1,1), ...

  8. yepnope First experience

    It's a project in full bloom , In the process of getting familiar with the code , See all kinds of front ends . back-end technology , This time there's another one yepnope The east east , Search for , It's not a new technology , Open official website , The notice that has been discarded is very eye-catching , But still provide relevant documents in github ...

  9. centos command

     alt + z Open the terminal ( Custom command )  su Switch to root

  10. Java--> A revised version of the licensing process

    --> This time, it's hard to encapsulate ... package com.xm.ddz; // The attributes of each card public class Card { private String flowerColor; ...