Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Connect to ORacle using C under Linux

Re: Connect to ORacle using C under Linux

From: Pete Finnigan <plsql_at_petefinnigan.com>
Date: Thu, 26 Feb 2004 15:35:05 +0000
Message-ID: <lvjJzwApIhPARx8M@peterfinnigan.demon.co.uk>


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 demo_rdbms.mk or rdbms_demo.mk - you will find it. Just type "make -f rdbms_demo.mk 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

-- 
Pete Finnigan
email:pete_at_petefinnigan.com
Web site: http://www.petefinnigan.com - Oracle security audit specialists
Book:Oracle security step-by-step Guide - see http://store.sans.org for details.
Received on Thu Feb 26 2004 - 09:35:05 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US