Click here to Skip to main content
15,884,388 members
Articles / Database Development / SQL Server
Article

ABCs of Pro*C

Rate me:
Please Sign up or sign in to vote.
1.10/5 (12 votes)
23 May 2007CPOL2 min read 49.2K   14   7
Basic understanding of Pro*C

Introduction

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.)

Why Pro*C?

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.

Overall Process

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.

History

<23-05-2007> First article has been created.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Author is a consultant. He is having more than 4 years of experience in designing and developing applications on Windows, UNIX and LINUX paltforms in C, C++ and Perl.

Vipul lives in Annapolis, MD, USA.

Comments and Discussions

 
Questionoracle pro*c to C # conversion Pin
Member 1374180622-Mar-18 10:59
Member 1374180622-Mar-18 10:59 
GeneralMy vote of 1 Pin
idil1025-Jun-09 23:24
idil1025-Jun-09 23:24 
GeneralArchaic Pin
Marc Clifton23-May-07 2:13
mvaMarc Clifton23-May-07 2:13 
GeneralRe: What on earth???? Pin
MrGoodly23-May-07 4:17
MrGoodly23-May-07 4:17 
GeneralRe: What on earth???? Pin
yafan23-May-07 5:03
yafan23-May-07 5:03 
To be fair:

It could be that the gentleman is a contractor and is working on a legacy project.

Indian software companies do a lot of outsourcing globally and, I imagine, get tasked with working on a lot of legacy systems.

I can't imagine why else you'd advocate using this technique, unless, as you said, they are living in a cave somewhere...







AnswerRe: Archaic Pin
vipulparmar23-May-07 18:03
vipulparmar23-May-07 18:03 
GeneralRe: Archaic Pin
Richard Blake30-Oct-07 7:10
Richard Blake30-Oct-07 7:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.