Running Perl sample programs
Perl sample programs demonstrate how to connect and run database operations with the IBM® database server..
Before you begin
Before running the Perl sample programs, you must install the latest DBD::DB2
driver for Perl DBI. For information about how to obtain the latest driver, see
CPAN.
About this task
The Perl sample programs for Db2® database are available in the sqllib/samples/perl directory.
Procedure
To run a Perl sample program through the Perl interpreter:
Enter the interpreter name and the program name (including
the file extension):
- If connecting locally on the server:
perl dbauth.pl
- If connecting from a remote client:
perl dbauth.pl sample <userid> <password>
Some of the sample programs require you to run support files. For example,
the
tbsel
sample program requires several tables
that are created by the tbselcreate.db2
CLP script.
The tbselinit
script (UNIX),
or the tbselinit.bat
batch file (Windows), first calls tbseldrop.db2
to
drop the tables if they exist, and then calls tbselcreate.db2
to
create them. Therefore, to run the tbsel
sample program,
issue the listed commands:- If connecting locally on the server:
tbselinit perl tbsel.pl
- If connecting from a remote client:
tbselinit perl tbsel.pl sample <userid> <password>
Note: For a remote client, you must modify the connect statement
in the
tbselinit
or tbselinit.bat
file
to hardcode your user ID and password: db2 connect to sample
user <userid> using <password>