DB2 Version 10.1 for Linux, UNIX, and Windows

Running a script file in CLPPlus

In CLPPlus, a script file can be run in many ways. You can provide the name of a script file that contains database commands and SQL commands as a token for the CLPPLUS command. You can run a script file using the START CLPPlus command. You can also run a script by copying its contents into the CLPPlus SQL buffer using the GET CLPPlus command and then issuing the RUN CLPPlus command.

About this task

This task shows how to run a script with the CLPPLUS command. For other methods, see the related links.

Procedure

To run a script with the CLPPLUS command:

Run the CLPPLUS command, specifying a script name. For example, consider a script file named dept_query.sql:
SET PAGESIZE 9999
SET ECHO ON
SELECT * FROM DEPT;
EXIT
To run the dept_query.sql script on the default SAMPLE database on port 50000 with a user name of db2user and password passw0rd, issue the following command:
clpplus db2user/passw0rd @dept_query

The dept_query.sql script file is run after the user connects to the database. When the script is run, the commands SET PAGESIZE and SET ECHO ON and the statement SELECT * FROM are issued.

The output of the script is as follows. ECHO ON displays the statement that was issued in the script file, and the values of DEPT are displayed up to a page limit of 9999.
C:\DB2\9.7\db2 > clpplus db2user/passw0rd @dept_query.sql
	Connected to DB2 v 9.7 (localhost:5444/db2sampl) AS db2user

SQL>
SELECT * FROM dept;

DEPT      NODNAME     LOC
------    ----------  -----------
   10     ACCOUNTING  NEW YORK
   20     RESEARCH    DALLAS
   30     SALES       CHICAGO
    4     OPERATIONS  BOSTON

SQL > 

EXIT