Re: Connect to ORacle using C under Linux

From: Pete Finnigan <>
Date: Thu, 26 Feb 2004 15:35:05 +0000
Message-ID: <>

Hi Yanick,

It depends on how complicated you want to get. You can use either Pro*C or OCI. Pro*C is a pre-compiler that translates embedded SQL statements into C function calls and then the C compiler compiles the result into a binary. OCI is an API provided by Oracle to allow you to connect to an Oracle database and to access and modify data or to perform structural changes such as adding a new table. OCI is harder to learn as there are multiple C calls required for each action required in the database. To complicate further there are two OCI API's the older OCI7 and the newer OCI8, I would bite the bullet and use OCI8 as the older API will be discontinued at some point.

You best approach is to look at $ORACLE_HOME/oci/samples for OCI and for Pro*C there are a number of demos available, some in
$ORACLE_HOME/plsql/demo and some in $ORACLE_HOME/rdbms/demo - just run a
$ find $ORACLE_HOME -name "*.pc" -print and you will find a few.

For OCI use cdemo81.c as this shows how to connect and also how to select and update data. You can modify this as a starting point. You can build the examples with the demo makefile, i think its called or - you will find it. Just type "make -f cdemo81" if you want to make that file. Pro*C is similar there should be a demo make file.

hope this helps a bit,

kind regards


Pete Finnigan
Web site: - Oracle security audit specialists
Book:Oracle security step-by-step Guide - see for details.
Received on Thu Feb 26 2004 - 16:35:05 CET

Original text of this message