调用存储过程
下面的例子展示了如何调用存储过程:
/*获取语句句柄*/
rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt);
/*预编译SQL,调用函数时使用{call funcname(?,...)} */
SQLPrepare(hstmt, (SQLCHAR *) "{ call length(?) }", SQL_NTS);
cbParams[paramno] = SQL_NTS;
/*绑定参数 */
rc = SQLBindParameter(hstmt, paramno, SQL_PARAM_INPUT,
SQL_C_CHAR, /* value type */
SQL_CHAR, /* param type */
20, /* column size */
0, /* dec digits */
“testvalue”, /* param value ptr */
0, /* buffer len */
&cbParams[paramno] /* StrLen_or_IndPtr */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
/*执行*/
rc = SQLExecute(hstmt);
CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt);