Setting Up the Perl Environment

Several steps are involved with setting up a DB2 UDB Perl environment:

  • A DB2 UDB Developer's edition is needed. The earliest supported version of DB2 UDB that is supported, at the time of writing, is V5.2.

  • The database being accessed must be cataloged properly. If the database is remote, a node must also be cataloged.

  • DB2 UDB CLI bind files must be bound to the database.

  • The CLI environment must be configured using the CCA or the db2cli.ini file must be edited directly. Because the Perl DBD module is built on top of the CLI layer it is important to remember that the settings in the db2cli.ini file will affect connections to DB2.

  • The Perl environment needs to be installed onto the DB2 client machine. This can be found on the Perl Web site: www.perl.com.

  • The Perl DBI needs to be installed and compiled on the client machine. This can be found on the Perl Web site: www.perl.com/CPAN-local/modules/by-module/DBI/.

  • The DB2 UDB Perl DBD needs to be installed and compiled on the client machine. This can be found on the Perl Web site: www.perl.com/CPAN-local/modules/by-module/DBD/.

DB2 UDB Installation

The DB2 UDB Quick Beginnings Guide is a good reference for installing DB2 UDB, the specifics of which are outside the scope of this book. Just be sure the appropriate DB2 UDB product is installed so that the Perl DBD module can be compiled.

Database Cataloging

Again, the DB2 UDB Quick Beginnings Guide is an excellent reference for cataloging a local or remote database. This can be accomplished by either using the command-line prompt with DB2 commands or by using the CCA; the details of which will be left to that manual.

CLI Bind Files

The bind files required for CLI applications are automatically bound when the first CLI application (including Perl) connects to the database. (An exception to this rule occurs when the first application connects from a run-time client. This environment does not include DB2 bind files.) The bind may not be successful if the user does not have BINDADD authority on the database. Therefore, the database administrator may be required to bind the necessary files manually using the DB2 UDB BIND command or the CCA. Each of the supported DB2 servers use different bind files. See Table 13.1.

Table 13.1. CLI Bind List Files
Bind FileDB2 Server
db2cli.lstDB2 UDB (OS/2, Windows, UNIX)
ddcsvm.lstDB2 for VM (SQL/DS)
Ddcsvse.lstDB2 for VSE (SQL/DS)
Ddcsmvs.lstDB2 for OS/390 (MVS/ESA)
ddcs400.lstDB2 for OS/400

For example, to manually bind the CLI packages from a DB2 UDB command window on Windows NT against a DB2 UDB for AIX database, you would issue the following command after connecting to the database:

DB2 BIND @db2cli.lst MESSAGES db2cli.msg GRANT PUBLIC

Likewise, if the DB2 database resides on OS/390, you could use the command:

DB2 BIND @ddcsmvs.lst BLOCKING ALL SQLERROR CONTINUE MESSAGES mvsbind.msg GRANT PUBLIC

The syntax for the BIND command can be referred to in the DB2 UDB Command Reference Guide.

Configuring CLI

It may be necessary to alter the behavior of a deferred prepare. As of DB2 V5.0, deferred prepare is on by default. This means that a statement is not prepared during a prepare statement but rather deferred until the execute statement. Because there is no way to alter this behavior from the statement level, it must be altered in the db2cli.ini file.

The db2cli.ini file is located in the sqllib/cfg directory of the instance owner in UNIX systems, or the sqllib directory for OS/2 and Windows operating systems.

An example db2cli.ini file is shown here. There are many more options that can be specified in the CLI configuration file. The first line is a comment about the section of the file. Multiple databases can be configured in this file. The second line contains the database alias name in the brackets, [DB2MALL]. The DB2MALL database can still be accessed from a DB2 UDB CLI application without an entry in the db2cli.ini file, but if there is no section for the DB2MALL database, all of the default values for the parameters will be used. This may not be desirable. The line below the database name alters the behavior of all connections to that data source name. The supported keywords are defined in the DB2 UDB Call Level Interface Guide and Reference.

; Comment goes here
[DB2MALL]
DEFERREDPREPARE=1

The DB2 UDB CCA allows you to configure the CLI environment without editing the db2cli.ini file directly. The interface is easy to use and explains each parameter that can be modified.

Installing Perl

At the time of writing, the minimum supported version of Perl for the DBD::DB2 module was 5.004_04. Be sure to check the README file of the DBD::DB2 module for the latest requirements. Perl can be downloaded from the Perl Web site in either its binary form or as source code. If the binary form is not available for your platform, you will need to compile the source code on your target platform. If you choose the latter option, you will naturally need a compiler. Be sure to follow all instructions provided by the Perl Web site.

Installing the Perl DBI

Installing the Perl DBI module is fairly straightforward. Be sure to read the README file that comes with the compressed TAR file. The minimum version (at the time of writing; make sure that you refer to the README file for DBD::DB2) of the DBI module that DB2 requires is 0.93. After the file downloaded has been extracted to a directory, installation follows the usual Perl practice of:

  • perl Makefile.PL

  • make (nmake for Windows with the Microsoft Visual C++ compiler)

  • make test (nmake test for Windows)

  • make install—only if test passes (nmake install for Windows)

Installing the DBD::DB2 Module

The DBD::DB2 driver is currently supported on many platforms. For the latest information refer to www.software.ibm.com/data/db2/perl. The following operating systems and C compilers were supported at the time of writing:

AIXOperating Systems:
  • AIX V4.1.4 and later

Compilers:
  • IBM C for AIX V3.1 and later

HP-UXOperating Systems:
  • HP-UX V10.10 with Patch Levels: PHCO_6134, PHKL_5837, PHKL_6133, PHKL_6189, PHKL_6273, PHSS_5956

  • HP-UX V10.20

  • HP-UX V11

Compilers:
  • HP C/HP-UX V10.32

  • HP C Compiler V11.00.00 (for HP-UX Version 11)

LinuxOperating Systems:
  • Linux Redhat V5.1 with kernel 2.0.35 and glibc V2.0.7

Compilers:
  • gcc V2.7.2.3 or later

SolarisOperating Systems:
  • Solaris V2.5.1

  • Solaris V2.6

Compilers:
  • SPARCompiler C V4.2

Windows NTOperating Systems:
  • Microsoft Windows NT V4 or later

Compilers:
  • Microsoft Visual C++ V5.0 or later


The downloadable database driver from DB2 for Perl is shipped in the form of a compressed TAR file. After this has been extracted be sure to read the README file and the CAVEATS file. Installation usually follows the normal Perl practice of:

  • perl Makefile.PL

  • make (nmake for Windows with the Microsoft Visual C++ compiler)

  • make test (nmake test for Windows)

  • make install—only if test passes (nmake test for Windows)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.179.139