Hello,

Whenever I attempt to execute more than one resultset-producing SP in one soci::session, I get this error thrown the second time:
"Commands out of sync; you can't run this command now"

This is with the latest version of SOCI. Example code to reproduce attached.

What is the correct way to go about resolving this issue? I'd like to ditch the current workaround of closing and reopening the session after each such stored procedure call if at all possible.

Thanks,
Gevorg
#include <iostream>
#include <exception>

#include <soci.h>
#include <soci-mysql.h>

int main()
{
        try {
                std::string connection_string;
                getline( std::cin, connection_string );
                soci::session sql( soci::mysql, connection_string );
                std::string s;
                sql << "CALL sp_a()", soci::into( s );  // 1.
                std::cout << s << std::endl;
                sql << "CALL sp_b()", soci::into( s );  // 2. this one throws 
exception unless (1) is commented out
                std::cout << s << std::endl;

                return 0;
        }
        catch ( std::exception &e ) {
                std::cerr << "Error: " << e.what() << '\n';
        }
        catch ( ... ) {
                std::cerr << "UNKNOWN EXCEPTION\n";
        }

        return 1;
}
DELIMITER $$

CREATE PROCEDURE sp_a()
BEGIN
        SELECT 'Result_A';
END $$

CREATE PROCEDURE sp_b()
BEGIN
        SELECT 'Result_B';
END $$

DELIMITER ;
------------------------------------------------------------------------------
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to