printf("sqlo_open failed: %sn", sqlo_geterror(dbh));
return 0;
}
/* sqlo_print(sd);*/
while (0 == sqlo_fetch(sd,1))
{
v = sqlo_values(sd, NULL, 1);
printf("%4s%6s%19s%21s%11sn", v[0], v[1], v[2], v[3], v[4]);
}
#ifdef CLOSE_CURSOR
if (0 > sqlo_close(sd))
{
printf("sqlo_open failed: %sn", sqlo_geterror(dbh));
return 0;
}
#endif
return 1;
}
/*-------------------------------------------------------------------------
* Select with prepare/execute/fetch.
*-----------------------------------------------------------------------*/
int test_select2( int dbh )
{
int sth;
int nkey[MAX_ITERS];
char ckey[MAX_ITERS][6];
double nval[MAX_ITERS];
char cval[MAX_ITERS][21];
char dval[MAX_ITERS][11];
int wc = 1;
int status;
int i;
short nkeyl[MAX_ITERS];
short ckeyl[MAX_ITERS];
short nvall[MAX_ITERS];
short cvall[MAX_ITERS];
short dvall[MAX_ITERS];
int rows_fetched = 0;
int rows_fetched_total = 0;
int rows_to_fetch;
int done_fetching = 0;
char * select_stmt =
"SELECT NKEY, CKEY, NVAL, CVAL, DVAL FROM T_SQLORA_TEST WHERE NKEY >= :1";
printf("Test select via classic methodsn");
/* Select all and display */
if (0>(sth = sqlo_prepare(dbh, select_stmt)))
{
printf("sqlo_prepare failed: %sn", sqlo_geterror(dbh));
return 0;
}
/* Bind input */
if (SQLO_SUCCESS !=
(sqlo_bind_by_name(sth, ":1", SQLOT_INT, &wc, sizeof(int), NULL, 0)))
{
printf("sqlo_bind_by_name failed: %sn", sqlo_geterror(dbh));
return 0;
}
/* Define Output */
if (SQLO_SUCCESS !=
(sqlo_define_by_pos(sth, 1, SQLOT_INT, nkey, sizeof(int),0,nkeyl, 1) ||
sqlo_define_by_pos(sth, 2, SQLOT_STR, ckey[0], 6, 0, ckeyl, 1) ||
sqlo_define_by_pos(sth, 3, SQLOT_FLT, nval, sizeof(double),0,nvall,1) ||
sqlo_define_by_pos(sth, 4, SQLOT_STR, cval[0], 21, 0, cvall, 1) ||
sqlo_define_by_pos(sth, 5, SQLOT_STR, dval[0], 11, 0, dvall, 1)))
{
printf("sqlo_define_by_pos failed: %sn", sqlo_geterror(dbh));
return 0;
}
rows_to_fetch = 3;
rows_fetched = rows_to_fetch;
status = sqlo_execute(sth, rows_to_fetch);
if (status < 0)
{