7.1 What is Oracle::OCI?Oracle::OCI takes Perl/Oracle connectivity to a new level. It combines the power of a typical C programming environment with a much friendlier Perl interface. Oracle::OCI gives you access to every bit of functionality available in OCI, and it operates seamlessly with any version of the Oracle database. It lets you do the more complex direct data loading, threading, and large object (LOB) handling that until now has required C programming. Oracle::OCI communicates with Oracle at a very low level, which also gives it excellent performance. If you've ever wanted to get that 15-hour batch extract program down to 5 hours, Oracle::OCI may be just the thing you've been looking for. There is a price for this power, however. When you use Oracle::OCI, you must code in such a way that there is close to a line-by-line correspondence between your Perl script and OCI, with Oracle::OCI acting as the router in between. In this chapter we'll first look at the Oracle Call Interface itself and what it provides. Then we'll explain how to install Oracle::OCI and use it to get the most effective and efficient connectivity between your Perl programs and the Oracle database. Next we'll look at several examples of the code you might write to issue OCI calls from Perl to Oracle. We'll compare the line-by-line Oracle::OCI approach to the Perl DBI approach and, finally, we'll suggest a way you can mix and match the two approaches. Let's start by looking at Figure 7-1, which illustrates the various modules now providing connections to the Oracle database. This figure shows the full set of modules and how they relate, assuming that you have all of them. Most people don't yet have the Oracle::OCI module, and they rely entirely on the Perl DBI and DBD::Oracle link. This situation may change in the future, however, and Oracle::OCI may become integral for everyone. Figure 7-2 compares the two architectures (Oracle::OCI vs. Perl DBI/DBD::Oracle). Figure 7-1. The Perl triumvirate: Perl DBI, DBD::Oracle, and Oracle::OCIFigure 7-2. Comparing the Oracle::OCI and the Perl DBI/DBD::Oracle architectures |