The intention of writing this Pro*C tutorial is to provide basic understanding of the oracle PRO*C precompiler. PRO*C is a useful tool provided by ORACLE to simplify the task of writing complex C program interacting with ORACLE database. (Of course it could be useful with other databases as well.)
The benefits of writing application using Pro*C are as follows:
- Pro*C facilitates developer to use SQL in application programs to access ORACLE directly.
- User can create highly flexible user interfaces and integrate involving oracle.
- Pro*C helps fine tune the application and also allows close monitoring of resource use, SQL statement execution as well as various runtime indicator.
- Using Pro*C saves time though adds a step in the development process. It translates embedded SQL into the calls to the oracle runtime library (SQLLIB).
- Pro*C also allows optional sementic check of embedded SQL, analyses host variables and also defines mappings of structure into columns.
The overall process starting from writing Pro*C code to executable is as follows:
- A Pro*C file can be written using notepad or any ordinary editor with extension .pc containing Pro*C code.
- Pro*C precompiler takes this example .pc file as an input and generates corresponding .c file. This .c file contains complex code containing corresponding code in C. (For java developers -- its similar to webserver which takes .jsp file as input and generates corresponding complex servlet code.)
- The generated .c file is needed to be compiled through C compilers with necessary headers and linking
library in path (e.g. Windows users need to compile in VC++ (or GCC, Borland C, etc. depending upon development tool. and UNIX user through GCC. Ideally path setting needs to be done in configuration files.)
- User can directly utilize the function call (Written in your Pro*C file) into program by including necessary
header files in your program.
How is it used generally?
The basic uses of Pro*C are:
- Pro*C is generally used in large applications which uses C/C++ as a middle tier which contains actual business logic and interaction with database.
- For small scale systems, all the transaction processing which needed to be performed in C/C++, all functions are preffered to be implemented using Pro*C and generated .dll (.o and/or .so for UNIX) are used while writing front end applications.
- For business web applications where your business logic needs to be implemented in C. Pro*C is very useful to avoid complex coding as well as user can write extension for other languages such as perl, python depending on the application architecture.
<23-05-2007> First article has been created.