我使用 Freebsd 8.0 amd64,mysql-client-5.1.61, mysql-connector-c++-1.1.0, mysql-server-5.1.61 和 gcc 4.2.1 为什么这行得通
stmt->execute("CREATE PROCEDURE p(OUT retval VARCHAR(50)) BEGIN SELECT \"Ulf joined MySQL more than 5 years ago\" INTO retval; END;");
pstmt.reset(con->prepareStatement("CALL p(@output)"));
pstmt->execute();
pstmt.reset(con->prepareStatement("SELECT @output AS _answer"));
res.reset(pstmt->executeQuery());
while (res->next())
cout << "\t... _answer: " << res->getString("_answer") << endl;
这不是
stmt->execute("CREATE PROCEDURE p(OUT retval VARCHAR(50),OUT retval1 VARCHAR(50)) BEGIN SELECT \"Ulf joined MySQL more than 5 years ago\" INTO retval;SELECT \"Ulf joined MySQL more than 5 years ago\" INTO retval1; END;");
pstmt.reset(con->prepareStatement("CALL p(@out1,@out2)"));
pstmt->execute();
pstmt.reset(con->prepareStatement("SELECT @out1 AS vOut,@out2 as vOut2"));
res.reset(pstmt->executeQuery());
while (res->next())
cout << res->getString("vOut1") << res->getString("vOut2") << endl;
并返回ERR: MySQLPreparedResultSet::getString: invalid 'columnIndex' (MySQL error code: 0, SQLState: )
有什么问题?