Db2 executing command crash shell

db2

I have a simple ksh script that executes db2 queries, such as

#!/bin/ksh
#some initialization
#step1,2,3
set -e
db2 -x "select * from table a "
#step4

The main issue seems to be caused by the db2 command. If the query returns records the shell script works perfectly fine. But if the query returns no results, then step4 will not be executed at all, and exits the shell immediately. This doesn't make sense. If the query didn't return anything, the shell still shouldn't crash anyway.

Can someone explain the reason ?

it turns out that there is a option "set -e" in the long script which will capture all unhandled execptional scenarios and abort the shell execution.

Best Answer

I guess it has something to do with the fact, that db2 will return an error code of 1 when no records were found.