rc = SQLExecDirect(hstmt, (SQLCHAR *) "SET intervalstyle=postgres_verbose", SQL_NTS);
/* Prepare a statement */
- rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t FROM testtab1 WHERE t = ?", SQL_NTS);
+ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t::varchar(25) FROM testtab1 WHERE t = ?", SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt);
/* bind param */
*/
/* Prepare a statement */
- rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t FROM testtab1 WHERE id = ?", SQL_NTS);
+ rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT id, t::varchar(25) FROM testtab1 WHERE id = ?", SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt);
/* bind param */
&cbParam1 /* StrLen_or_IndPtr */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
- /* Test SQLNumResultCols, called before SQLExecute() */
+ /* Test SQLNumResultCols/SQLDescribeCol, called before SQLExecute() */
rc = SQLNumResultCols(hstmt, &colcount);
CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt);
printf("# of result cols: %d\n", colcount);
+ for (i = 1; i <= colcount; i++)
+ {
+ SQLCHAR colname[64];
+ SQLSMALLINT collen, type, scale;
+ SQLULEN len;
+
+ rc = SQLDescribeCol(hstmt, i, colname, sizeof(colname), &collen, &type, &len, &scale, NULL);
+ CHECK_STMT_RESULT(rc, "SQLDescribeCol failed", hstmt);
+ printf("col:%d name=%s type=%d len=%d\n", i, colname, type, (int) len);
+ }
/* Execute */
rc = SQLExecute(hstmt);