|
This section contains the following topics: How You Can Build and Install the Ingres Perl DBI Extension Build the DBD::Ingres Extension Test and Install the DBD::Ingres Extension |
To connect to Ingres from Perl, you must meet the following prerequisites:
You can download the latest version of Perl from http://www.perl.org/.
System requirements and other installation information are contained in the Ingres Perl DBI Extension readme, available from http://www.ingres.com/downloads/prod-download-drivers.php.
The Ingres Perl DBI is a database extension for the Perl DBI system that enables access to Ingres databases. It is built on top of the standard Perl DBI extension. The driver supports database access to Ingres 2006 and prior versions of Ingres.
The source code is available for download from the Comprehensive Perl Archive Network (CPAN) repository for Perl extensions at http://search.cpan.org/dist/DBD-Ingres/.
For more information, see the Ingres Perl DBI Driver readme, available from http://search.cpan.org/~htoug/DBD-Ingres-0.51/Ingres.pm.
Before you can use the Ingres Perl extension, DBD::Ingres, you must first build and install it. Building the extension requires a C development environment and Ingres ESQL/C. The steps required to build the extension are common to all platforms except for a slight difference between the commands used.
Note: To build the extension on Windows, Microsoft's Visual Studio .NET compiler and Platform SDK are required.
Perform the following procedure to download and build the DBD::Ingres extension.
To download and build the extension
Among other tools for Windows, you could use WinZip.
Ensure that II_SYSTEM and platform-specific paths have LIB and INCLUDE defined.
perl Makefile.PL
nmake
Perform the following procedure to test and install the DBD::Ingres extension.
To test and install the extension
set DBI_DSN=perldb
nmake test
If everything is set up correctly, the message "All tests successful" is displayed.
nmake install
To use the Ingres Perl module, the Perl DBI module must be included using the use statement. The data source name supplied to the DBI->connect() method is used determine the correct DBD module to load to make the database connection.
The following is a simple segment of code that connects to the Ingres database iidbdb and selects from iitables.
use DBI;
# Define the database to used
$dbname = "dbi:Ingres:iidbdb";
# Connect to the database
my $dbh = DBI->connect($dbname, "", "");
# Prepare a statement
$cursor = $dbh->prepare("SELECT table_name, table_owner FROM iitables order by table_name asc");
# Execute the cursor
$cursor->execute;
# Fetch the results
while ($row = $cursor->fetchrow_arrayref) {
print(DBI::neat_list($row), "\n");
}
# Close the cursor
$cursor->finish;