#include <stdio.h>
#include <stdlib.h>
#include "examples.h"
int ex20(sqlo_db_handle_t dbh, double min_income)
{
sqlo_stmt_handle_t sth;
int status;
unsigned int i,j;
char ** v;
char ** col_names;
unsigned int *nl;
unsigned short *vl;
unsigned int nc;
int nrows;
sth = reopen_cursor(dbh, min_income);
printf("Employees with SAL > %-8.2f:\n", min_income);
nrows = 0;
while ( SQLO_SUCCESS == (status = (sqlo_query_result(sth,
&nc,
&v,
&vl,
&col_names,
&nl
)))) {
if ( nrows == 0 )
{
for (i = 0; i < nc; ++i)
printf("%-*s ", nl[i]+4, col_names[i]);
printf("\n");
for (i = 0; i < nc; ++i) {
for (j = 0; j < nl[i]+4; ++j) {
putchar('-');
}
putchar('+');
}
putchar('\n');
}
for (i = 0; i < nc; ++i)
printf("%-*s ", (vl[i] > nl[i] ? vl[i] : nl[i])+4, v[i]);
printf("\n");
++nrows;
}
if (0 > status) {
error_exit(dbh, "sqlo_query_result");
}
if ( SQLO_SUCCESS != sqlo_close(sth))
error_exit(dbh, "sqlo_close");
return 1;
}