List:MySQL++« Previous MessageNext Message »
From:Jonathan Wakely Date:September 15 2010 2:52pm
Subject:Re: How to execute multiple SQL instructions in one step
View as plain text  
On 15 September 2010 15:34, Attila wrote:
> Hi Everyone,
>
> I am using the following to try and execute a lock on table and then in
> update:
>
> const char* sql = "LOCK TABLES MyTable WRITE;UPDATE MyTable SET status=
> 'STARTED' WHERE status_id= '7' AND address = 167473977; UNLOCK TABLES;";
>
> // m_pConnection is a mysqlpp::Connection
> mysqlpp::Query query = m_pConnection->query(sql);
> mysqlpp::StoreQueryResult storeResult(query.store());
>
> However this gives me a syntax error. Is there any way to accomplish the
> above in one call?

You need mysqlpp::MultiStatementsOption, as shown in this tutorial:
http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#connopts

c.f. http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html
Thread
How to execute multiple SQL instructions in one stepAttila15 Sep
  • Re: How to execute multiple SQL instructions in one stepJonathan Wakely15 Sep
    • Re: How to execute multiple SQL instructions in one stepAttila15 Sep