long longparam;
SQL_INTERVAL_STRUCT intervalparam;
SQLSMALLINT colcount;
+ SQLSMALLINT dataType;
+ SQLULEN paramSize;
+ SQLSMALLINT decDigits;
+ SQLSMALLINT nullable;
test_connect();
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/*** Test SQLBindParameter with SQLExecDirect ***/
+ printf("\nTesting SQLBindParameter with SQLExecDirect...\n");
/* bind param */
strcpy(param1, "bar");
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
+ /*** Test SQLDescribeParam ***/
+ printf("\nTesting SQLDescribeParam...\n");
+
+ rc = SQLFreeStmt(hstmt, SQL_RESET_PARAMS);
+ CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
+
+ /* Prepare a statement */
+ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t FROM testtab1 WHERE id = ?", SQL_NTS);
+ CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt);
+
+ rc = SQLDescribeParam(hstmt, 1, &dataType, ¶mSize, &decDigits, &nullable);
+ CHECK_STMT_RESULT(rc, "SQLDescribeParams failed", hstmt);
+ printf("Param 1: type %s; size %d; dec digits %d; %s\n",
+ datatype_str(dataType), paramSize, decDigits, nullable_str(nullable));
+ /* bind param */
+ strcpy(param1, "3");
+ cbParam1 = SQL_NTS;
+ rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
+ SQL_C_CHAR, /* value type */
+ SQL_CHAR, /* param type */
+ 20, /* column size */
+ 0, /* dec digits */
+ param1, /* param value ptr */
+ 0, /* buffer len */
+ &cbParam1 /* StrLen_or_IndPtr */);
+ CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
+
+ /* Test SQLNumResultCols, called before SQLExecute() */
+ rc = SQLNumResultCols(hstmt, &colcount);
+ CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt);
+ printf("# of result cols: %d\n", colcount);
+
+ /* Execute */
+ rc = SQLExecute(hstmt);
+ CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt);
+
+ /* Fetch result */
+ print_result(hstmt);
+
+ rc = SQLFreeStmt(hstmt, SQL_CLOSE);
+ CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
+
/* Clean up */
test_disconnect();