List:MySQL++« Previous MessageNext Message »
From:Jonathan Wakely Date:July 4 2011 10:43am
Subject:Re: exception in subqueries
View as plain text  
On 4 July 2011 11:29, Access-Dev wrote:
> Hi,
>
> I m currently using mysqlpp in a MFC/Windows/C++ project , and I
> experiencing exceptions while calling sub queries:
>
>
> Here is the error I get if I activate exceptions:
>
> Unhandled exception at 0x75acb760 in UA_OnlineTracking.exe: Microsoft C++
> exception: mysqlpp::BadQuery at memory location 00012ebc8..
>
>
> My Code :
>
>
> ITF::String GetSingleField(mysqlpp::Connection & c,const char *sql){
>
>      ITF::String out = "";
>
>      mysqlpp::Query query = c.query(sql);
>
>      mysqlpp::Row row;
>
>      if (mysqlpp::UseQueryResult res = query.use()) {
>
>            row = res.fetch_row();
>            out = MPP_TO_ITF_STRING( row.at(0) );
>
>      }
>
>
>      return out;
>
>
>      }
>
>
>
>
> Looks like the if statement is never ( query.use() ) is never excecuted ,
> even if I run a very simple query like "SELECT 1;"
>
> If there a specific way to handle subqueries?

"SELECT 1;" is not a sub-query.

You don't need the semi-colon in your query, the API knows that the
end of the string is the end of the query.

To chain together multiple queries in a single string you can separate
them with ';' and enable the mysqlpp::MultiStatementOption (see
http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#connopts)
but for a single query just use "SELECT 1" instead of "SELECT 1;"

The examples in the mysql++ source distribution are useful, you should
review them and compare your failing code to the examples to find why
they work and yours doesn't. See
http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#examples
Thread
exception in subqueriesAccess-Dev4 Jul
  • Re: exception in subqueriesJonathan Wakely4 Jul
    • Re: exception in subqueriesAccess-Dev4 Jul
      • RE: exception in subqueriesShaun Brown4 Jul
        • Re: exception in subqueriesAccess-Dev4 Jul
          • Re: exception in subqueriesWarren Young5 Jul
      • Re: exception in subqueriesJonathan Wakely4 Jul