Chapter 2. Connecting to Oracle

The Oracle Call Interface (OCI) is the Oracle software that allows the outside world access to the hidden core of the Oracle database. An open source application—or any other type of non-Oracle program—can use OCI to connect directly to Oracle via its internal SQL engine. OCI is a complex product, and this short chapter can’t do justice to all of its capabilities. We’ll cover only the fundamentals here, examining the basic Application Programming Interface (API) of OCI and how it is typically used with open source software. We’ll introduce OCI and its main functions, and we’ll explain how it relates to Open DataBase Connectivity (ODBC) and Java DataBase Connectivity (JDBC).

Although you can access OCI directly, most developers prefer a simpler and more convenient interface. As an example of how open source applications use such interfaces to communicate with OCI, we’ll take a close look at how Perl applications use the Perl Database Interface (DBI) module (and its Oracle-specific driver, DBD::Oracle) to connect to Oracle databases. We’ve chosen Perl here because it was one of the first open source languages to communicate directly with Oracle; the interface dates from 1990, with Kevin Stock’s original work on Oraperl. We’ll describe other interfaces in their respective chapters (for example, Tcl with its Oratcl interface, and Python with its DBOracle interface, in Chapter 3). Throughout this book, we’ll mention, as appropriate, how various open ...

Get Oracle and Open Source now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.