printf("sqlo_bind_param failed failed: %sn", sqlo_geterror(dbh) );
return 0;
}
else
{
if (SQLO_SUCCESS != sqlo_execute(sth, 1))
{
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
printf ("ip1: %.16f, ip2: %d, op1: %d, op2: %sn", ip1, ip2, op1, op2);
}
else
{
printf("sqlo_open failed: Status: %d, %sn", sth, sqlo_geterror(dbh) );
return 0;
}
return 1;
}
/*-------------------------------------------------------------------------
* test_insert with bind by pos
*-----------------------------------------------------------------------*/
int test_insert( int dbh )
{
int nkey;
char ckey[6];
double nval;
char cval[21];
char dval[11];
int sth;
char * insert_stmt =
"INSERT INTO T_SQLORA_TEST (NKEY, CKEY, NVAL, CVAL, DVAL) VALUES (:NKEY, :CKEY, :NVAL, :CVAL, :DVAL)";
printf("Testing Insert (bind by pos)n");
if (!create_table(dbh))
return 0;
nkey = 100;
strcpy(ckey, "CKEY");
nval = 1234567890.001;
strcpy(cval,"aaaaaaaaaaaaaaaaaaaa");
strcpy(dval,"01-JUL-00");
if (0 <= (sth = sqlo_prepare(dbh, insert_stmt)))
{
if (SQLO_SUCCESS !=
(sqlo_bind_by_pos(sth, 1, SQLOT_INT, &nkey, sizeof(int),0,0) ||
sqlo_bind_by_pos(sth, 2, SQLOT_STR, ckey, 6,0,0) ||
sqlo_bind_by_pos(sth, 3, SQLOT_FLT, &nval, sizeof(double),0,0) ||
sqlo_bind_by_pos(sth, 4, SQLOT_STR, cval, 21,0,0) ||
sqlo_bind_by_pos(sth, 5, SQLOT_STR, dval, 11,0,0)
))
{
printf("sqlo_bind_param failed failed: %sn", sqlo_geterror(dbh) );
return 0;
}
else
{
if (SQLO_SUCCESS != sqlo_execute(sth, 1))
{
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) );