return 0;
}
#endif
do_select(dbh);
}
else
{
printf("sqlo_open failed: Status: %d, %sn", sth, sqlo_geterror(dbh) );
return 0;
}
printf("finished test_insertn");
return 1;
}
/*-------------------------------------------------------------------------
* test_array_insert
*-----------------------------------------------------------------------*/
int test_array_insert( int dbh )
{
int nkey[MAX_ITERS];
char ckey[MAX_ITERS][6];
double nval[MAX_ITERS];
char cval[MAX_ITERS][21];
char dval[MAX_ITERS][11];
short nind[MAX_ITERS];
short cind[MAX_ITERS];
short dind[MAX_ITERS];
int sth, i, j;
int status;
char * insert_stmt =
"INSERT INTO T_SQLORA_TEST (NKEY, CKEY, NVAL, CVAL, DVAL) VALUES (:NKEY, :CKEY, :NVAL, :CVAL, :DVAL)";
printf("Testing Array Insert (bind by name)n");
if (!create_table(dbh))
return 0;
/* setup bind arrays */
for ( i = 0 ; i < MAX_ITERS; i++)
{
nkey[i] = i+1;
sprintf(ckey[i], "%c", A + i % 26 );
nval[i] = 1234567890.0 + i / 1000.0;
for (j = 0; j < 20; j++)
cval[i][j] = a + i % 26;
cval[i][20] = ;
sprintf(dval[i], "%02d-JUL-00", (i % 30 ) + 1);
nind[i] = 0;
cind[i] = 0;
dind[i] = 0;
}
if (0 <= (sth = sqlo_prepare(dbh, insert_stmt)))
{
if (SQLO_SUCCESS !=
(sqlo_bind_by_name(sth, ":NKEY", SQLOT_INT, &nkey[0], sizeof(int), NULL,1) ||
sqlo_bind_by_name(sth, ":CKEY", SQLOT_STR, &ckey[0], 6, NULL,1) ||
sqlo_bind_by_name(sth, ":NVAL", SQLOT_FLT, &nval[0], sizeof(double), nind,1) ||
sqlo_bind_by_name(sth, ":CVAL", SQLOT_STR, &cval[0], 21, cind,1) ||
sqlo_bind_by_name(sth, ":DVAL", SQLOT_STR, &dval[0], 11, dind,1)
))
{
printf("sqlo_bind_param failed failed: %sn", sqlo_geterror(dbh) );
return 0;
}
else
{
if (SQLO_SUCCESS != sqlo_execute(sth, MAX_ITERS))
{
printf("sqlo_execute failed: %sn", sqlo_geterror(dbh) );
return 0;
}
}
#ifdef CLOSE_CURSOR
if (SQLO_SUCCESS != sqlo_close(sth))
{
printf("sqlo_close failed: %sn", sqlo_geterror(dbh) );
return 0;
}
#endif
do_select(dbh);
}
else
{
printf("sqlo_open failed: Status: %d, %sn", sth, sqlo_geterror(dbh) );
return 0;
}
if (SQLO_SUCCESS != (status = sqlo_commit(dbh))) {
printf("commit failed (%d): %sn", status, sqlo_geterror(dbh));
return 0;
}
return 1;
}