00001
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 #include "examples.h"
00005
00006 sqlo_stmt_handle_t do_select2(sqlo_db_handle_t dbh, double min_salary)
00007 {
00008 sqlo_stmt_handle_t sth;
00009 int status;
00010 char name[64];
00011 short name_rlen;
00012 short name_ind;
00013 short sal_ind;
00014 double salary = min_salary;
00015
00016 sth = prepare_cursor(dbh, &salary);
00017
00018
00019 if (SQLO_SUCCESS !=
00020 (sqlo_define_by_pos(sth, 1, SQLOT_STR, name, sizeof(name), &name_ind, &name_rlen, 0)) ||
00021 (sqlo_define_by_pos(sth, 2, SQLOT_FLT, &salary, sizeof(salary), &sal_ind, 0, 0))) {
00022 error_exit(dbh, "sqlo_define_by_pos");
00023 }
00024
00025 status = sqlo_execute(sth, 0);
00026 if ( 0 > status)
00027 error_exit(dbh, "sqlo_execute");
00028
00029 while ( SQLO_SUCCESS == (status = sqlo_fetch(sth, 1))) {
00030 printf("Name=%-8s Salary=%6.2f\n", name, salary);
00031 }
00032
00033 if (status != SQLO_NO_DATA)
00034 error_exit(dbh, "sqlo_fetch");
00035
00036 return sth;
00037 }
00038