List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:October 26 2010 1:19pm
Subject:Re: Problems with storein and template queries
View as plain text  
On Oct 26, 2010, at 1:37 AM, Florian Feldbauer wrote:

> In pricipal my code looks like that:

Yes, I got that from your original post.  I'm asking you to modify one of the examples to
show the symptom, because I've tried, and haven't succeeded.  Here's my diffs for
tquery1:

> Index: examples/tquery1.cpp
> ===================================================================
> --- examples/tquery1.cpp	(revision 2679)
> +++ examples/tquery1.cpp	(working copy)
> @@ -49,12 +49,14 @@
>  		// Build a template query to retrieve a stock item given by
>  		// item name.
>  		mysqlpp::Query query = con.query(
> -				"select * from stock where item = %0q");
> +				"select * from %0 where item = %1q");
>  		query.parse();
>  
>  		// Retrieve an item added by resetdb; it won't be there if
>  		// tquery* or ssqls3 is run since resetdb.
> -		mysqlpp::StoreQueryResult res1 = query.store("Nürnberger Brats");
> +		cout << "Q: " << query.str("stock", "Nürnberger Brats") <<
> endl;
> +		mysqlpp::StoreQueryResult res1 = query.store("stock",
> +				"Nürnberger Brats");
>  		if (res1.empty()) {
>  			throw mysqlpp::BadQuery("UTF-8 bratwurst item not found in "
>  					"table, run resetdb");


That code runs just fine here.  Try it on your system.  If it fails there, please post
your system details: OS, CPU type, compiler vendor, compiler version...

My suggestion to use "%0q" for the table parameter is bogus, though.  You have to use
backticks to quote a table name in SQL, not single quotes as SQL requires for values. 
The template query mechanism doesn't know how to do backticks, so you'd have to put them
into the template query string yourself if you needed them.  I did that, too, and it also
works.
Thread
Problems with storein and template queriesFlorian Feldbauer25 Oct
  • Re: Problems with storein and template queriesWarren Young25 Oct
    • Re: Problems with storein and template queriesFlorian Feldbauer25 Oct
      • Re: Problems with storein and template queriesWarren Young26 Oct
        • Re: Problems with storein and template queriesFlorian Feldbauer26 Oct
          • Re: Problems with storein and template queriesWarren Young26 Oct
            • Re: Problems with storein and template queriesWarren Young26 Oct
              • Re: Problems with storein and template queriesFlorian Feldbauer27 Oct
                • Re: Problems with storein and template queriesWarren Young3 Nov
  • Re: Problems with storein and template queriesAdrian Cornish25 Oct
    • Re: Problems with storein and template queriesWarren Young25 Oct