13 messages in com.mysql.lists.plusplusRe: Weird parsing of templated query
FromSent OnAttachments
Steven Van Ingelgem14 Jul 2007 10:49 
Andrew Sayers14 Jul 2007 13:00 
Warren Young16 Jul 2007 04:54 
Steven Van Ingelgem16 Jul 2007 05:13 
Warren Young16 Jul 2007 05:30 
Steven Van Ingelgem16 Jul 2007 05:38 
Warren Young16 Jul 2007 06:35 
Steven Van Ingelgem16 Jul 2007 07:04 
Warren Young16 Jul 2007 07:35 
Steven Van Ingelgem16 Jul 2007 07:37 
roberto previdi16 Jul 2007 08:01 
Warren Young16 Jul 2007 09:49 
roberto previdi16 Jul 2007 10:16 
Subject:Re: Weird parsing of templated query
From:roberto previdi (hari@yahoo.it)
Date:07/16/2007 08:01:57 AM
List:com.mysql.lists.plusplus

I tried this:

try { mysqlpp::Query q(TheDb::Instance().getConnection()); q <<"select * from `Mob` where objectId=%0:objectId"; q.parse(); mysqlpp::SQLQueryParms parms(&q); parms["objectId"]=4; mysqlpp::Result result; result = q.store(parms); [...] }

catch(exception &e)

{

cout << string(e.what())<< endl;

}

but i get this exception:

std::exception: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'select * from `Mob` where objectId=4' at line 1

So the substitution is working correctly (yeah!) but something is still not
correct.. If i try that query in mysql it works perfectly.. Maybe i don't catch correctly
the exception?

roby

----- Original Message ---- From: Steven Van Ingelgem <s.va@gmail.com> To: plus@lists.mysql.com Sent: Monday, July 16, 2007 4:37:43 PM Subject: Re: Weird parsing of templated query

Ok!

I'll try that :-).

Thanks!

On 7/16/07, Warren Young <mysq@etr-usa.com> wrote:

Steven Van Ingelgem wrote:

It would be ok however if I could pass a vector<SQLString>. But not entirely happy with it... Because I would like to use also named templated values. And what if I want to bind parameters not in a logical order?

I've got it: you want to call the execute(SQLQueryParams&) et al. overloads. They're not documented, but they're trivial; just look at them in lib/query.cpp.

They're removed right now in svn, but I can see that we're just trying to reinvent the need for them. I guess I'll just put them back. Meanwhile, use them in good health.

Maybe you could add some feature for MySQL 5+ (prepared statements are possible from then right?) where you could build a prepared statement?

This is orthogonal to the current discussion. It's already on the Wishlist, but even if it existed now, it wouldn't solve your problem.