Problem solve Get help with specific problems with your technologies, process and projects.

Connecting a C or C++ program to the database

I am new to Oracle. Right now I'm into a project on C++/SCO Unix/Oracle 8. I have written a C++ program, which I need to connect to the database. Would you please guide me in this regard?

The easiest way to get a C or C++ program connected to an Oracle database is by using the Oracle C precompiler, called Pro*C. This let's you put a simple SQL statement directly in your C program. Then you run your C program through the Pro*C precompiler and it changes those simple SQL calls into complex C statements using Oracle's C libraries. Then you compile your application.

At the heart of Pro*C is the Oracle C Interface (OCI). You can use OCI directly, but it is much harder to code. But it is faster and generally works better than Pro*C.

For more information on Pro*C, refer to Oracle's developer site called Technet (http://technet.oracle.com). You can find code examples for Pro*C right there!

For More Information

  • What do you think about this answer? E-mail the editors at [email protected] with your feedback.
  • The Best Oracle Web Links: tips, tutorials, scripts, and more.
  • Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
  • Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
  • Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.

Dig Deeper on Oracle database design and architecture