C program with Oracle database access

Hey,

  I want to access oracle database through Unix C programming.. Can you through me some light on that...

You need the Oracle ProC pre-compiler installed on your development machine. Basically, it allows you to embed SQL commands within your C programs. The pre-compiler simply converts all of the embedded SQL code into pure C code that may then be compiled into an executable. Your source code for ProC programs will have an extension of .pc (instead of .c). It works great and performace is outstanding!

If anyother way to access the Oracle database..? Thanks for an Info. Thanks yeslekmc.

>If anyother way to access the Oracle database..? Thanks for an Info.
None, unless you yourself want to use the SQLCA, SQLDA, .. libraries, which is what the Precompiler exactly does with your .pc program.

You can use the statement listed below to login to Oracle. It will run from within a shell script. I use a shell script to tie together several Oracle spool files and other programs

sqlplus -s /nolog @[filename] $var1

Example:

In shell script, prompt user to enter db_usr_name, db_passwd into one shell variable.

echo "Enter Oracle username and password"
stty -echo
read ora_pwd
stty echo

#ora_pwd format = user_name/passwd[@db_link]

sqlplus -s /nolog @spool_file_name $ora_pwd

#Enter this in the first line of the spool file and it will connect to #the Oracle DB.

connect &1.[@db_link]
set headsep !
set term off
set verify off
set colsep ' '
set feedback off
set timing off
set linesize 80
set pagesize 1000
...

Let me know if that helps or if you have any other questions.

You can use OCI ( Oracle Call Interface) functions and libraries within you C/C++ code. This way of implementation is of the lowest level,enabling interaction between C/C++ application and that of Oracle.