Command line processor return codes
This section provides information about the command line processor return codes.
When the command line processor finishes processing a command or an SQL statement, it returns a return (or exit) code. These codes are transparent to users executing CLP functions from the command line, but they can be retrieved when those functions are executed from a shell script.
db2 get database manager configuration
if [ "$?" = "0" ]
then echo "OK!"
fi
- Code
- Description
- 0
- Db2® command or SQL statement executed successfully
- 1
- SELECT or FETCH statement returned no rows
- 2
- Db2 command or SQL statement warning
- 4
- Db2 command or SQL statement error
- 8
- Command line processor system error
The command line processor does
not provide a return code while a user is executing statements from
interactive mode, or while input is being read from a file (using
the -f
option).
When
a CLP command is used with the +w
option, warnings
are suppressed, 1 and 2 codes are never returned, and 0 is returned
in such cases.
A return code is available only after the user quits interactive mode, or when processing of an input file ends. In these cases, the return code is the logical OR of the distinct codes returned from the individual commands or statements executed to that point.
For example, if a user in interactive mode issues commands resulting in return codes of 0, 1, and 2, a return code of 3 will be returned after the user quits interactive mode. The individual codes 0, 1, and 2 are not returned. Return code 3 tells the user that during interactive mode processing, one or more commands returned a 1, and one or more commands returned a 2.
A return code of 4 results from a negative SQLCODE returned by aDb2 command or an SQL statement. A return code of 8 results only if the command line processor encounters a system error.
If commands are issued from an input file or in interactive
mode, and the command line processor experiences
a system error (return code 8), command execution is halted immediately.
If one or more Db2 commands
or SQL statements end in error (return code 4), command execution
stops if the -s
(Stop Execution on Command Error)
option is set; otherwise, execution continues.