Freitag, 25 of April of 2014

Perl and DB2

Supported Operating Systems

  • AIX: Perl 5.8 or later, DBI 1.41 or later
  • HP-UX on IPF (IA64): Perl 5.8 or later, DBI 1.41 or later
  • Linux on x86 (32-bit DB2 instances and compilers only): Perl 5.8 or later, DBI 1.41 or later
  • Linux on x64: Perl 5.8 or later, DBI 1.41 or later
  • Linux on POWER® (PowerPC®, Power Systems™ Servers, pSeries®): Perl 5.8 or later, DBI 1.41 or later
  • Linux on zSeries® (s/390x): Perl 5.8 or later, DBI 1.41 or later
  • Solaris on UltraSPARC: Perl 5.8 or later, DBI 1.41 or later
  • Solaris on x64: Perl 5.8 or later, DBI 1.41 or later
  • Windows on x86 (32-bit DB2instances only): Perl 5.8 or later, DBI 1.41 or later
  • Windows on x64: Perl 5.8 or later, DBI 1.41 or later

Installation of DB2 Perl Interface for L/U/W

 Pre-requisites:

  • Linux: Perl version 5.8 or above
  • Windows: ActivePerl version 5.8 or above
  • DBI version 1.53 and above
  • IBM DB2 client version 9 fp2 and above

Pre-requisites for manual installation from scratch:

  • C compiler
    • Windows: MingW compiler and the dmake utility or the VC compiler
    • Linux: gcc compiler
    • AIX: xlc compiler

Windows – ActiveState Perl

Install the binary version of DBD::DB2 module by issuing the following commands

Linux – CPAN installation

As for any cpan module issue the cpan command specifying DBD::DB2 as the module name, after setting the necessary environment variables as below

Compiling and Installing the Driver

Untar the archive and issue the following commands

Read more.

Links

Null Indicator in Perl

  • NULL values are represented by undefined values in Perl
  • In a scalar context, fetchrow[_array] returns the value of the first field. An undef is returned if there are no more rows or if an error occurred. Since that undef can’t be distinguished from an undef returned because the first field value was NULL, you should exercise some caution if you use fetchrow[_array] in a scalar context.
  • print “First column MAY return NULL\n” if $sth->{NULLABLE}->[0];
    NULLABLE (array-ref, read-only)
    Returns a reference to an array indicating the possibility of each column returning a null. Possible values are 0 (or an empty string) = no, 1 = yes, 2 = unknown.
  • Here’s how to convert fetched NULLs (undefined values) into empty strings: