Note: The return code is available when the CLP has processed the entire file, and the return code is a “logical or” of the return codes from each statement. If some statements returned 2, other statements returned 1 and the rest of the statements were successful (return code 0) then the return code for the entire file is 3.

Invocation of the CLP is identical on Windows and UNIX. The only difference between Windows and UNIX is how the return code is checked. We discuss how to perform error handling on each platform and give a full example for the Windows platform.

UNIX script

On the UNIX platform the result of the last executed command is available in

“$?”. In example Example 5-7we show three different ways to check the return code of a call to the command line processor.

Example 5-7 Check the command line processor return code on UNIX

#------------------------------------------------

#Call the command line processor

#------------------------------------------------

db2 -o- -l itsodb.log -f itsodb.ddl

#------------------------------------------------

# Example A

#------------------------------------------------

if [ "$?" -eq "4" ]; then exit 4

fi exit 0

#------------------------------------------------

# Example B

#------------------------------------------------

if [ "$?" -ge "4" ]; then exit 4

fi exit 0

#------------------------------------------------

# Example C

#------------------------------------------------

case “$?” in

"0" “1” “2” “3”) exit 0;;

"4" “5” “6” “7”) exit 4;;

"*")

224DB2 Deployment Guide

Page 238
Image 238
IBM manual Unix script, 224 DB2 Deployment Guide