or all the statements are executed within the same unit of work. If executing all the statements in one unit of work is preferred, add -c-as an option. For example:

db2 -c- -f itsodb.ddl

The CLP also has options to direct the output and log the messages. We show how to obtain a complete history in a log file, and how to run the CLP in silent or non-silent mode.

￿-lfilename

This option tells the command line processor to log commands and statements executed in a history file.

￿-o

This option control whether the CLP displays output data and messages to standard output. Default value is on. To run the CLP in silent mode, add -o-as an option. For example:

db2 -o- -f itsodb.ddl

The typical scenario is to use the -loption to obtain a log, which can be used for verification and error handling, and then turn output on/off with the -ooption based on the progress information requirements in the user interface.

CLP return codes

When the CLP finishes processing a command or an SQL statement, it returns a return code. You can validate the return code in the script and take actions based on the value.

Table 5-1lists the CLP return codes. The -soption has impact on whether the execution will stop or continue for the various return codes. C in the last column indicates that the execution will continue, while the S indicates that the execution will stop.

Table 5-1 CLP return codes and the impact of the -s option

Code

Description

-s/-s-

 

 

 

0

DB2 command or SQL statement executed successfully

C/C

 

 

 

1

SELECT or FETCH statement returned no rows

C/C

 

 

 

2

DB2 command or SQL statement warning

C/C

 

 

 

4

DB2 command or SQL statement error

C/S

 

 

 

8

Command line processor system error

S/S

 

 

 

Chapter 5. Deploying pre-configured databases

223

Page 237
Image 237
IBM DB2 manual 223, CLP return codes and the impact of the -s option