00001 /* $Id: ex6.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 reopen_cursor(sqlo_db_handle_t dbh, double min_income) 00007 { 00008 static sqlo_stmt_handle_t sth = SQLO_STH_INIT; 00009 int argc = 0; 00010 const char * argv[1]; 00011 char hlp[64]; 00012 00013 sprintf(hlp, "%f", min_income); 00014 00015 argv[argc++] = hlp; 00016 00017 if (SQLO_STH_INIT == sth) { 00018 /* first time, open a new cursor */ 00019 if ( 0 > (sqlo_open2(&sth, dbh, 00020 "SELECT ENAME, SAL FROM EMP WHERE SAL >= :1", 00021 argc, argv))) { 00022 error_exit(dbh, "sqlo_open"); 00023 } 00024 } else { 00025 /* next time, bind again with new variables */ 00026 if ( 0 > sqlo_reopen(sth, argc, argv)) 00027 error_exit(dbh, "sqlo_reopen"); 00028 } 00029 00030 return sth; 00031 } 00032 /* $Id: ex6.c 221 2002-08-24 12:54:47Z kpoitschke $ */