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.
This task shows how to run a script with the CLPPLUS command. For other methods, see the related links.
To run a script with the CLPPLUS command:
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.
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