List:MySQL++« Previous MessageNext Message »
From:Florian Feldbauer Date:March 18 2011 2:59pm
Subject:Re: Problems with storein and template queries
View as plain text  
I have attached the modified source of tquery1.cpp.
When executing, the program returns:
  "Error: Not enough parameters to fill the template."

Best regards
Florian

On Fri, 18 Mar 2011, Adrian Cornish wrote:

> On Fri, Mar 18, 2011 at 3:58 AM, Florian Feldbauer
> <florian@stripped> wrote:
>       I just made a downgrade to mysql++ 3.0.9 and now the storein works fine with my
> template query.
>       So there seems to be a bug in the 3.1.0 release! A colleague of mine
>       reported the same problem using mysql++ 3.1.0 on a gentoo machine.
>
>       Best regards
>       Florian
> 
> 
> Florian,
> 
> Could you send a complete modified version of one of the example programs or a
> complete program in itself (with db
> schema) that reproduces this exact problem.
> 
> 
> Adrian
> 
>

-- 
-------------------------------------
| Florian Feldbauer                 |
| Ph.D. student                     |
|                                   |
| Institut für Experimentalphysik I |
| Ruhr-Universität Bochum           |
| Universitätsstr. 150              |
| D-44780 Bochum                    |
|                                   |
| Office: NB 2/173                  |
| Phone:  (+49)234 / 32-23538       |
| Fax:    (+49)234 / 32-14170       |
| Web:    http://www.ep1.rub.de     |
-------------------------------------
/***********************************************************************
 tquery1.cpp - Example similar to ssqls3.cpp, except that it uses
	template queries instead of SSQLS.

 Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
 (c) 2004-2009 by Educational Technology Resources, Inc.  Others may
 also hold copyrights on code in this file.  See the CREDITS.txt file
 in the top directory of the distribution for details.

 This file is part of MySQL++.

 MySQL++ is free software; you can redistribute it and/or modify it
 under the terms of the GNU Lesser General Public License as published
 by the Free Software Foundation; either version 2.1 of the License, or
 (at your option) any later version.

 MySQL++ is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with MySQL++; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 USA
***********************************************************************/

#include "cmdline.h"
#include "printdata.h"
#include "stock.h"

#include <iostream>

using namespace std;

int
main(int argc, char *argv[])
{
	// Get database access parameters from command line
	mysqlpp::examples::CommandLine cmdline(argc, argv);
	if (!cmdline) {
		return 1;
	}

	try {
		// Establish the connection to the database server.
		mysqlpp::Connection con(mysqlpp::examples::db_name,
				cmdline.server(), cmdline.user(), cmdline.pass());

		// Build a template query to retrieve a stock item given by
		// item name.
		mysqlpp::Query query = con.query(
				"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");
		vector<stock> res1;
		query.storein(res1, "stock", "Nürnberger Brats");

		if (res1.empty()) {
			throw mysqlpp::BadQuery("UTF-8 bratwurst item not found in "
					"table, run resetdb");
		}

		// Replace the proper German name with a 7-bit ASCII
		// approximation using a different template query.
		query.reset();		// forget previous template query data
		query << "update stock set item = %0q where item = %1q";
		query.parse();
		mysqlpp::SimpleResult res2 = query.execute("Nuerenberger Bratwurst",
							   //				res1[0][0].c_str());
							   res1[0].item );

		// Print the new table contents.
		print_stock_table(query);
	}
	catch (const mysqlpp::BadQuery& er) {
		// Handle any query errors
		cerr << "Query error: " << er.what() << endl;
		return -1;
	}
	catch (const mysqlpp::BadConversion& er) {
		// Handle bad conversions
		cerr << "Conversion error: " << er.what() << endl <<
				"\tretrieved data size: " << er.retrieved <<
				", actual size: " << er.actual_size << endl;
		return -1;
	}
	catch (const mysqlpp::Exception& er) {
		// Catch-all for any other MySQL++ exceptions
		cerr << "Error: " << er.what() << endl;
		return -1;
	}

	return 0;
}
Thread
Re: Problems with storein and template queriesFlorian Feldbauer15 Mar
  • Re: Problems with storein and template queriesWarren Young15 Mar
    • Re: Problems with storein and template queriesWarren Young16 Mar
      • Re: Problems with storein and template queriesFlorian Feldbauer16 Mar
      • Re: Problems with storein and template queriesFlorian Feldbauer18 Mar
        • Re: Problems with storein and template queriesAdrian Cornish18 Mar
          • Re: Problems with storein and template queriesFlorian Feldbauer18 Mar
            • Re: Problems with storein and template queriesWarren Young18 Mar
              • Fixing 3.1.0 ABI breakage (Re: Problems with storein and templatequeries)Andrey Ponomarenko19 Sep