List:MySQL++« Previous MessageNext Message »
From:Jim Date:July 20 2008 3:13pm
Subject:Template queries aren't working for me.
View as plain text  
I placed the following code after line 77 or so (just before the return 
0;) in the simple1.cpp example:

                try {
                    query.reset();
                    string insertStr="insert into stock (item, 
num,weight,price, sdate,description) values ";
                    insertStr+=" ('item A', 22, 3.4, 5.33, now(),'a 
simple thing')";

                    query << insertStr ;
                    cout <<"The query is now "<<query<<endl;
                    query.parse();
                    SimpleResult res = query.execute();
                    cout <<res.rows()<<" rows affected"<<endl;
                    query.reset();
                    insertStr="insert into stock (item, 
num,weight,price, sdate,description) values ";
                    insertStr+=" (%0q, %1, %2, %3,  now(),%4q)";
                    query << insertStr ;
                    res = query.execute("item G", 12, 13.4, 15.39, "a 
complex thing");
                    cout <<res.rows()<<" rows affected"<<endl;
                    cout <<"The query is now "<<query<<endl;

                } catch (mysqlpp::Exception e) {
                    cout << "Test error: " << e.what() << endl;
                }
However the template insert doesn't seem to be working even though it 
looks the same to my eyes.

Here's the output:

The query is now insert into stock (item, num,weight,price, 
sdate,description) values  ('item A', 22, 3.4, 5.33, now(),'a simple thing')
1 rows affected
0 rows affected
The query is now insert into stock (item, num,weight,price, 
sdate,description) values  (%0q, %1, %2, %3,  now(),%4q)

And inspecting the database does confirm the insert didn't happen.  No 
error messages were trapped either. 

This is running the latest released version 3,  with threading enabled 
on a Centos 4.4 platform recompiled and installed myself from source.  I 
synthesized this because my program was failing with an error like "you 
have an error in line 1 near '' consult your version of mysql...". Or 
words to that effect.

 From rpm:

mysql-5.0.27-1.el4.centos
mysql-devel-5.0.27-1.el4.centos
mysqlclient14-4.1.14-4.2.c4.1
mysql-server-5.0.27-1.el4.centos
mysql++-3.0.4-1


Anyone?

Thanks,
Jim.

Thread
Template queries aren't working for me.Jim20 Jul
  • Re: Template queries aren't working for me.Warren Young21 Jul