ex11.c

Example for using sqlo_define_by_pos and sqlo_execute.

00001 /* $Id: ex11.c 221 2002-08-24 12:54:47Z kpoitschke $ */
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;       /* statement handle */
00009   int status;                   /* return code of sqlo_... */
00010   char name[64];                /* output variable for NAME */
00011   short name_rlen;              /* returned length of NAME */
00012   short name_ind;               /* NULL indicator for NAME */
00013   short sal_ind;                /* NULL indicator for SALARY */
00014   double salary = min_salary;   /* input variable for SALARY */
00015 
00016   sth = prepare_cursor(dbh, &salary); /* see ex10.c */
00017 
00018   /* define output */
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 /* $Id: ex11.c 221 2002-08-24 12:54:47Z kpoitschke $ */

Generated on Mon May 21 13:42:17 2007 for libsqlora8 by  doxygen 1.4.7