00001
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 #include "examples.h"
00005
00006
00007
00008 int ex20(sqlo_db_handle_t dbh, double min_income)
00009 {
00010 sqlo_stmt_handle_t sth;
00011 int status;
00012 unsigned int i,j;
00013 char ** v;
00014 char ** col_names;
00015 unsigned int *nl;
00016 unsigned short *vl;
00017 unsigned int nc;
00018 int nrows;
00019
00020 sth = reopen_cursor(dbh, min_income);
00021
00022
00023 printf("Employees with SAL > %-8.2f:\n", min_income);
00024
00025
00026 nrows = 0;
00027
00028 while ( SQLO_SUCCESS == (status = (sqlo_query_result(sth,
00029 &nc,
00030 &v,
00031 &vl,
00032 &col_names,
00033 &nl
00034 )))) {
00035
00036 if ( nrows == 0 )
00037 {
00038
00039 for (i = 0; i < nc; ++i)
00040 printf("%-*s ", nl[i]+4, col_names[i]);
00041 printf("\n");
00042 for (i = 0; i < nc; ++i) {
00043 for (j = 0; j < nl[i]+4; ++j) {
00044 putchar('-');
00045 }
00046 putchar('+');
00047 }
00048 putchar('\n');
00049 }
00050
00051
00052 for (i = 0; i < nc; ++i)
00053 printf("%-*s ", (vl[i] > nl[i] ? vl[i] : nl[i])+4, v[i]);
00054
00055 printf("\n");
00056
00057 ++nrows;
00058 }
00059
00060 if (0 > status) {
00061 error_exit(dbh, "sqlo_query_result");
00062 }
00063
00064 if ( SQLO_SUCCESS != sqlo_close(sth))
00065 error_exit(dbh, "sqlo_close");
00066
00067 return 1;
00068
00069 }
00070
00071
00072