Several steps are involved with setting up a DB2 UDB Perl environment:
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.
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.
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.
Bind File | DB2 Server |
---|---|
db2cli.lst | DB2 UDB (OS/2, Windows, UNIX) |
ddcsvm.lst | DB2 for VM (SQL/DS) |
Ddcsvse.lst | DB2 for VSE (SQL/DS) |
Ddcsmvs.lst | DB2 for OS/390 (MVS/ESA) |
ddcs400.lst | DB2 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.
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.
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 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)
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:
AIX | Operating Systems:
|
HP-UX | Operating Systems:
|
Linux | Operating Systems:
|
Solaris | Operating Systems:
|
Windows NT | Operating Systems:
|
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)
52.15.179.139