Just recently, a friend of mine sent me an OCI wrapper library I’d never run across, ciORA. ciORA was written by Zane Dodson and, unlike the other OCI wrapper libraries, ciORA calls are modeled after the stream-based standard I/O type C functions with error handling similar to that of errno.
An example of ciORA is as follows:
/* Logon and open an SQL descriptor for the SELECT statement that
supports both reading and writing. Cache 1 row for input, 5 on
output. */
ora_db = ora_dbo("scott", "tiger", NULL);
check();
ora_sql = ora_sqlo(ora_db, "SELECT month, day, holiday FROM holidays "
"WHERE (day < :1 or month = :2) "
"ORDER by monthid, day", 5, "%5s%d%35s", "%d%5s");
check();
/* Write the where clause value to the descriptor. */
ora_sqlw(ora_sql, 20, "Dec");
check();
/* Writing must occur before reading and must be completed before the
first read from an SQL descriptor that accepts both input and
output. Otherwise, you will get unpredictable results. */
/* Retrieve and output the query results. */
printf("First Query Results:\n");
printf("Month\t\tDay\t\tHoliday\n");
printf("-----\t\t---\t\t-------\n");
while (ora_sqlr(ora_sql, month, &day, holiday) > 0)
{
check();
printf("%s\t\t%d\t\t%s\n", month, day, holiday);
}
As ciORA is written using OCI7, you can use it with any version of Oracle from 7-11g. And, while its release status is alpha, it seems to work fairly well on the tests I’ve done. So, if you’re interested in another quick-and-easy OCI wrapper library, give ciORA a try.
About the attachment
Attached is the source code for ciORA with a few modifications for indentation and compiler flags to build on GCC. As this version is from 1994, I’ve contacted the author to see if he still maintains it. If not, I’ll pick it up and make it more widely available.