DB2 10.5 for Linux, UNIX, and Windows

Executing routines from Perl applications

DB2® client applications can access routines (stored procedures and user-defined functions) that are created by supported host languages or by SQL procedures. For example, the sample program spclient.pl can access the SQL procedures spserver shared library, if it exists in the database.

Before you begin

To build a host language routine, you must have the appropriate compiler set up on the server. SQL procedures do not require a compiler. The shared library can be built on the server only, and not from a remote client.

Procedure

To create SQL procedures in a shared library and then accesses the procedures from a Perl application:

  1. Create and catalog the SQL procedures in the library. For example, go to the samples/sqlpl directory on the server, and run the listed commands to create and catalog the SQL procedures in the spserver library:
        db2 connect to sample
        db2 -td@ -vf spserver.db2
  2. Go back to the perl samples directory (this can be on a remote client workstation), and run the Perl interpreter on the client program to access the spserver shared library:
    • If connecting locally on the server:
        perl spclient 
    • If connecting from a remote client:
         perl spclient sample <userid> <password>