【问题标题】:Call the stored procedure in mysql in odbc. The out parameter of the stored procedure in the execution result is invalid在odbc中调用mysql中的存储过程。执行结果中存储过程的out参数无效
【发布时间】:2022-06-15 09:38:15
【问题描述】:

下面是我的代码,用作输出参数的retCSNum的值没有改变。SQLExecDirect函数执行成功。

cout << "-------" << "Execute Procedures:" << "-------" << endl;
SQLCloseCursor(hStmt);
if (ret == SQL_SUCCESS)
    cout << "API Successfully!" << endl;
SQLCHAR countDep[SDepart_Len]= "CS";
SQLLEN countDepInd =SQL_NTS;

SQLLEN retCSNum = 0,retCSNumInd = SQL_IS_INTEGER;

ret = SQLBindParameter(hStmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,20,NULL,countDep,SDepart_Len*sizeof(char),&countDepInd);
if (ret == SQL_SUCCESS)
    cout << "Bind Successfully!" << endl;
ret = SQLBindParameter(hStmt, 2, SQL_PARAM_OUTPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &retCSNum, sizeof(int), &retCSNumInd);
if (ret == SQL_SUCCESS)
    cout << "Bind Successfully!" << endl;

ret = SQLExecDirect(hStmt, (SQLCHAR*)"{call CSNum(?,?)}", SQL_NTS);
SQLCHAR* state2 = new SQLCHAR[5];
cout << retCSNum << endl; // print 0 

【问题讨论】:

标签: c++ mysql odbc


猜你喜欢
  • 2020-01-09
  • 2015-05-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-15
  • 2023-04-07
相关资源
最近更新 更多