Oracle应用Linux开发C[11]

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

本文简介:

printf("test_exists(1) failed: %sn", sqlo_geterror(dbh));
return 0;
}


if (SQLO_SUCCESS ==
(status = sqlo_exists(dbh, "T_SQLORA_TEST", "CKEY", "xxx", NULL)))
printf("test_exists(2) failedn");
else
{
if (status != SQLO_NO_DATA)
{
printf("test_exists(2) failed: %sn", sqlo_geterror(dbh));
return 0;
}
else
printf("test_exists(2) okn");


}


return 1;
}


/*-------------------------------------------------------------------------
* test_count
*-----------------------------------------------------------------------*/
int test_count(int dbh)
{
int count;


if ((count = sqlo_count(dbh, "T_SQLORA_TEST", NULL, NULL, NULL)))
printf("test_count(1) okn");
else
{
printf("test_count(1) failed: %sn", sqlo_geterror(dbh));
return 0;
}


if ((count = sqlo_count(dbh, "T_SQLORA_TEST", "CKEY", "xxx", NULL)))
{
printf("test_count(2) failed (count=%d)n", count);
}
else
{
if (count < 0)
{
printf("test_count(2) failed (count=%d): %sn", count, sqlo_geterror(dbh));
return 0;
}
else
printf("test_count(2) okn");
}


return 1;
}


/*-------------------------------------------------------------------------
* int cleanup
*-----------------------------------------------------------------------*/
int cleanup(int dbh)
{
/* ignore all errors maybe they weren created */
sqlo_exec(dbh, "DROP TABLE T_SQLORA_TEST");
sqlo_exec(dbh, "DROP PACKAGE BODY SQLORA_TEST");
sqlo_exec(dbh, "DROP PACKAGE SQLORA_TEST");
return 1;
}
/*=========================================================================
* main
*=======================================================================*/
int main (int argc, char * argv[])
{
int status;
int dbh[MAX_LOOPS];
char * cstr;
int i;


printf("-------------------------------------------------------------nn");


if (argc > 1)
cstr = argv[1];
else
cstr = "scott/tiger";


status = sqlo_init(0);


if (SQLO_SUCCESS != status)
{
printf ("sql_init failed. Exitingn");
exit(1);
}


for (i = 0; i < MAX_LOOPS; i++)
{
status = sqlo_connect(&dbh[i], cstr);


if (SQLO_SUCCESS == status)
printf("Connected. dbh[i]=%dn", dbh[i]);
else
{
printf("connect failed with status: %d, %sn", status
, sqlo_geterror(dbh[i]));
exit(1);
}


if (!test_plsql(dbh[i]))
exit(1);


if (!test_insert(dbh[i]))
exit(1);


if (!test_array_insert(dbh[i])) /* bind by name */
exit(1);


if (!test_array_insert2(dbh[i])) /* bind by pos */
exit(1);


if (!test_exists(dbh[i]))
exit(1);


if (!test_count(dbh[i]))
exit(1);


if (!test_reopen(dbh[i]))
exit(1);


if (!test_select2(dbh[i]))

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

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

go top