I use the ODBC to connet the mysql server.
But when I use the SQLBindingParameter to bind a output data ,mysql return error code 1414.
Like this:
[MySQL][ODBC 5.3(w) Driver][mysqld-5.7.17-log]OUT or INOUT argument 3 for routine ????.user_login is not a variable or NEW pseudo-variable in BEFORE trigger (1414)
the procedure is under:
CREATE DEFINER=`root`@`localhost` PROCEDURE `user_login`(in user_name varchar(45),in user_password varchar(45),out status_code integer)
BEGIN
declare sel_result integer;
declare sel_pass varchar(45);
select count(*) into sel_result from account where Account_Name=user_name;
if sel_result=0 then
set status_code=0;
else
select Account_Password into sel_pass from account where Account_Name=user_name;
if sel_pass=user_password then
set status_code=1;
else
set status_code=2;
end if;
end if;
END
and the c++ program is under:
short status;
SQLINTEGER nameId = SQL_NTS;
RetCode = SQLBindParameter(hStmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 45, 0, (SQLPOINTER)name.c_str(), name.size(), &nameId);
if (RetCode != SQL_SUCCESS) {
HandleDiagnosticRecord(hStmt, SQL_HANDLE_STMT, RetCode);
}
RetCode = SQLBindParameter(hStmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 45, 0, (SQLPOINTER)password.c_str(), password.size(), &nameId);
RetCode = SQLBindParameter(hStmt, 3, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 10, 0, &status, sizeof(char), &nameId);
if (RetCode != SQL_SUCCESS) {
HandleDiagnosticRecord(hStmt, SQL_HANDLE_STMT, RetCode);
}
RetCode = SQLPrepare(hStmt, L"{call user_login(?,?,?) }", SQL_NTS);
if (RetCode != SQL_SUCCESS) {
HandleDiagnosticRecord(hStmt, SQL_HANDLE_STMT, RetCode);
}
RetCode = SQLExecute(hStmt);
if (RetCode != SQL_SUCCESS) {
HandleDiagnosticRecord(hStmt, SQL_HANDLE_STMT, RetCode);
}
But when I use the SQLBindingParameter to bind a output data ,mysql return error code 1414.
Like this:
[MySQL][ODBC 5.3(w) Driver][mysqld-5.7.17-log]OUT or INOUT argument 3 for routine ????.user_login is not a variable or NEW pseudo-variable in BEFORE trigger (1414)
the procedure is under:
CREATE DEFINER=`root`@`localhost` PROCEDURE `user_login`(in user_name varchar(45),in user_password varchar(45),out status_code integer)
BEGIN
declare sel_result integer;
declare sel_pass varchar(45);
select count(*) into sel_result from account where Account_Name=user_name;
if sel_result=0 then
set status_code=0;
else
select Account_Password into sel_pass from account where Account_Name=user_name;
if sel_pass=user_password then
set status_code=1;
else
set status_code=2;
end if;
end if;
END
and the c++ program is under:
short status;
SQLINTEGER nameId = SQL_NTS;
RetCode = SQLBindParameter(hStmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 45, 0, (SQLPOINTER)name.c_str(), name.size(), &nameId);
if (RetCode != SQL_SUCCESS) {
HandleDiagnosticRecord(hStmt, SQL_HANDLE_STMT, RetCode);
}
RetCode = SQLBindParameter(hStmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 45, 0, (SQLPOINTER)password.c_str(), password.size(), &nameId);
RetCode = SQLBindParameter(hStmt, 3, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 10, 0, &status, sizeof(char), &nameId);
if (RetCode != SQL_SUCCESS) {
HandleDiagnosticRecord(hStmt, SQL_HANDLE_STMT, RetCode);
}
RetCode = SQLPrepare(hStmt, L"{call user_login(?,?,?) }", SQL_NTS);
if (RetCode != SQL_SUCCESS) {
HandleDiagnosticRecord(hStmt, SQL_HANDLE_STMT, RetCode);
}
RetCode = SQLExecute(hStmt);
if (RetCode != SQL_SUCCESS) {
HandleDiagnosticRecord(hStmt, SQL_HANDLE_STMT, RetCode);
}