![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I have a simple stored procedure that works the first time, but when calling the second time I get "Lost connection to MySQL server during query". Does anybody have an idea what I am doing wrong? When replacing the query from the SP call query << "CALL sp_get_3()"; to query << "SELECT 3"; everything works fine. Thanks, Roger SP: DELIMITER // DROP PROCEDURE sp_get_3 // CREATE PROCEDURE sp_get_3() COMMENT 'Get 3' BEGIN SELECT 3; END // DELIMITER ; Code: m_con->set_option(Connection: pt_multi_statements, true);m_con->connect(m_args.db_name, m_args.db_hostname, m_args.db_user, m_args.db_password, m_args.db_port); // first call try { mysqlpp::Query query = m_con->query(); query << "CALL sp_get_3()"; query.parse(); cout << query.preview() << endl; mysqlpp::Result res = query.store(); if (res) { int num_results = res.size(); for (int i = 0; i < num_results; ++i) { mysqlpp::Row row = res.fetch_row(); if (!row.at(0).is_null()) { cout << "Result: " << row.at(0) << endl; } } } } catch (const mysqlpp::EndOfResults& er) { TRACE_FULL("query succeeded: %s", er.what()); } catch (exception& er) { TRACE_ERROR("query failed: %s", er.what()); } // second call, same code as above try { mysqlpp::Query query = m_con->query(); query << "CALL sp_get_3()"; query.parse(); cout << query.preview() << endl; mysqlpp::Result res = query.store(); if (res) { int num_results = res.size(); for (int i = 0; i < num_results; ++i) { mysqlpp::Row row = res.fetch_row(); if (!row.at(0).is_null()) { cout << "Result: " << row.at(0) << endl; } } } } catch (const mysqlpp::EndOfResults& er) { TRACE_FULL("query succeeded: %s", er.what()); } catch (exception& er) { TRACE_ERROR("query failed: %s", er.what()); } Output: CALL sp_get_3() Result: 3 CALL sp_get_3() query failed: Lost connection to MySQL server during query __________________________________________________ roger.urscheler (AT) siemens (DOT) com <mailto:roger.urscheler (AT) siemens (DOT) com> :: (905) 363-6400 x 6446 Chantry Networks, Siemens AG :: www.chantrynetworks.com http://www.chantrynetworks.com |
#3
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |