* to get the OID in output, and this information looks to be
* enough.
*/
- print_result_series(hstmt, sql_column_ids, 6);
+ print_result_series(hstmt, sql_column_ids, 6, -1);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
(SQLCHAR *) "testtab1", SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLTablePrivileges failed", hstmt);
print_result_meta(hstmt);
- print_result_series(hstmt, sql_tab_privileges_ids, 6);
+ print_result_series(hstmt, sql_tab_privileges_ids, 6, 5);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
* Print result only for the selected columns.
*/
void
-print_result_series(HSTMT hstmt, SQLSMALLINT *colids, SQLSMALLINT numcols)
+print_result_series(HSTMT hstmt, SQLSMALLINT *colids, SQLSMALLINT numcols, SQLINTEGER rowcount)
{
SQLRETURN rc;
+ SQLINTEGER rowc = 0;
printf("Result set:\n");
- while(1)
+ while (rowcount <0 || rowc < rowcount)
{
rc = SQLFetch(hstmt);
if (rc == SQL_NO_DATA)
int i;
SQLLEN ind;
+ rowc++;
for (i = 0; i < numcols; i++)
{
/*
colids = (SQLSMALLINT *) malloc(numcols * sizeof(SQLSMALLINT));
for (i = 0; i < numcols; i++)
colids[i] = i + 1;
- print_result_series(hstmt, colids, numcols);
+ print_result_series(hstmt, colids, numcols, -1);
free(colids);
}
SQLSMALLINT numcols);
extern void print_result_series(HSTMT hstmt,
SQLSMALLINT *colids,
- SQLSMALLINT numcols);
+ SQLSMALLINT numcols,
+ SQLINTEGER rowcount);
extern void print_result_meta(HSTMT hstmt);
extern void print_result(HSTMT hstmt);
extern const char *datatype_str(SQLSMALLINT datatype);