dwhitney67
December 9th, 2008, 05:36 PM
Hi,
I'm trying to string together multiple queries together into one transaction, yet for some reason MySQL is unhappy with the query construct I am putting together.
Here's what I have attempted:
mysqlpp::Connection con;
con.connect(0, server, user, pass);
con.select_db(db);
mysqlpp::Query query = con.query();
query << "BEGIN; ";
query << "INSERT INTO " << table << " VALUES('VTRIX', 'Vanguard International Value Fund', 1500.00, 30.00, '2005-01-01'); "
// ...
<< "INSERT INTO " << table << " VALUES('JORNX', 'Janus Orion Fund', 1500.00, 30.00, '2005-01-01'); ";
query << "COMMIT;";
query.execute();
This is the error I get:
Error: 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 '; INSERT INTO stocks VALUES('VTRIX', 'Vanguard International Value Fund', 1500.0' at line 1
I've tried running the query without the BEGIN/COMMIT statements, but then I get an error indicating that the second INSERT statement is "wrong".
When I manually issued two insert queries together using the MySQL shell interface, then everything worked fine.
Thus I cannot figure out what is the issue with MySQL++. Can anyone help?
I'm trying to string together multiple queries together into one transaction, yet for some reason MySQL is unhappy with the query construct I am putting together.
Here's what I have attempted:
mysqlpp::Connection con;
con.connect(0, server, user, pass);
con.select_db(db);
mysqlpp::Query query = con.query();
query << "BEGIN; ";
query << "INSERT INTO " << table << " VALUES('VTRIX', 'Vanguard International Value Fund', 1500.00, 30.00, '2005-01-01'); "
// ...
<< "INSERT INTO " << table << " VALUES('JORNX', 'Janus Orion Fund', 1500.00, 30.00, '2005-01-01'); ";
query << "COMMIT;";
query.execute();
This is the error I get:
Error: 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 '; INSERT INTO stocks VALUES('VTRIX', 'Vanguard International Value Fund', 1500.0' at line 1
I've tried running the query without the BEGIN/COMMIT statements, but then I get an error indicating that the second INSERT statement is "wrong".
When I manually issued two insert queries together using the MySQL shell interface, then everything worked fine.
Thus I cannot figure out what is the issue with MySQL++. Can anyone help?