Pro*C
From Oracle FAQ
⧼orafaq-jumptonavigation⧽⧼orafaq-jumptosearch⧽
Pro*C is a C/ C++ precompiler that lets you embed SQL calls directly into C-code. It is a lot more efficient coding-wise than using OCI.
- Pro*C - comes bundled with the Oracle client.
- Used for doing embedded SQL programming using C programs.
- Installation includes a proc or proc.exe executable under $ORACLE_HOME/bin
- Demo programs are under $ORACLE_HOME/precomp/demo/proc
Getting started on Unix
Start with this simple exercise (if you are running Unix):
- cd $ORACLE_HOME/demo/ directory, usually you find some Pro*C programs under $ORACLE_HOME/precomp/demo/proc/ or $ORACLE_HOME/plsql/demo/ directories, the suffix of the Pro*C programs are *.pc.
- Make sure that the following environment variables are set:
- LD_LIBRARY_PATH
- ORACLE_HOME
- PATH
- If you are running the following UNIX types the following environment variables need to be set:
- HP/UX - Set SHLIB_PATH to same value as LD_LIBRARY_PATH.
- AIX - Set LIBPATH to same value as LD_LIBRARY_PATH.
- AIX 4.3+ - Set LINK_CNTRL as L_PTHREADS_D7.
- Make sure that correct "C" Compiler version is present on your system:
- You may use "which" and "what" command, say which cc. Or use cc -v
- Relink the sample Pro*C programs:
- There is a sample make file called demo_plsql.mk, which relinks and compiles some of the sample Pro*C programs
- You can edit the file demo_plsql.mk to make necessary modifications to the database username/password (scott/tiger found in demo_plsql.mk) .etc.
- make -f demo_plsql.mk demos
- To Relink and make a single file use, make -f demo_plsql.mk sample1 or make -f demo_proc.mk build EXE=sample1 OBJS=sample1.o or make -f demo_proc.mk build EXE=sample1 OBJS=sample1.o PROCFLAGS="sqlcheck=semantics userid=username/password
- Running "make" yields the executable files. A makefile is a description file used by the UNIX 'make' utility. The makefile includes dependencies and rules for building a target executable. Such rules can be precompiling commands, compiling commands, linking commands, or commands for removing temporary files. The ultimate goal of the make utility is to build the final executable program using the rules contained within the makefile. The makefile can have any name.
- Now run the executable file ./sample1
Also see
- Sample Pro*C scripts (this site)