Oracle应用Linux开发C[10]

[入库:2005年9月21日] [更新:2007年3月24日]

本文简介:

/*-------------------------------------------------------------------------
* test_array_insert2 (by pos)
*-----------------------------------------------------------------------*/
int test_array_insert2( 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 i, j;
int status;
int sth;


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 pos)n");



if (!create_table(sth))
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_pos(sth, 1, SQLOT_INT, &nkey[0], sizeof(int), NULL,1) ||
sqlo_bind_by_pos(sth, 2, SQLOT_STR, &ckey[0], 6, NULL,1) ||
sqlo_bind_by_pos(sth, 3, SQLOT_FLT, &nval[0], sizeof(double), nind,1) ||
sqlo_bind_by_pos(sth, 4, SQLOT_STR, &cval[0], 21, cind,1) ||
sqlo_bind_by_pos(sth, 5, 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;
}



/*-------------------------------------------------------------------------
* test_exists
*-----------------------------------------------------------------------*/
int test_exists(int dbh)
{
int status;


if (SQLO_SUCCESS ==
(status = sqlo_exists(dbh, "T_SQLORA_TEST", "CKEY", "B", NULL)))
printf("test_exists(1) okn");
else
{

本文关键:Oracle应用Linux开发C
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top