Appendix B. The Essential Guide to Perl DBI
In this appendix we’ll examine the main elements of the application programming interface (API) for Perl DBI, the Perl module that’s responsible for communication between Perl and the Oracle database. Of course, there is much more to learn about Perl DBI. Consult the online and offline references listed in Chapter 1, for additional and much more complete resources.
As with virtually all CPAN modules, you can generate the full online documentation for both Perl DBI and DBD::Oracle (the Oracle-dependent driver for Perl DBI), with the two following commands:
$ perldoc DBI $ perldoc DBD::Oracle
DBI Class Methods
Before we connect to Oracle, we must establish a few DBI variable-naming conventions (listed in Table B-1).
Table B-1. Conventional Perl DBI variable names
Name |
Description |
---|---|
$dbh |
The database handle created on database connection. |
$sth |
The SQL statement handle. |
$drh |
The driver handle, mostly used internally by the Perl DBI package. |
$h |
Can represent any of the three main handles above. |
$rc |
A general DBI return code, mostly used in a Boolean context. |
$rv |
A general DBI return value, often used numerically. |
@ary |
A list of returned scalars, or a row fetched from the database. |
$rows |
The number of rows processed. |
$fh |
A file handle, often used to change any default output from STDOUT. |
undef |
Perl’s generic undefined value is used in DBI for NULLs. |
%attr |
A general name for hashes used to store ... |
Get Perl for Oracle DBAs 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.