a=`$db2 -x "select A from tablename where z in (select z from tablename Q where condition fetch first 1 rows only ) with ur"`
b=`$db2 -x "select B from tablename where z in (select z from tablename Q where condition fetch first 1 rows only) with ur"`
$db2 connection ...........W
c=`$db2 -x "select C from tablename W where R in ('$a') with ur"`
this is a part in my script.
The problem is the value of a is not getting substituted in '$a'. Please help.
There is nothing in what you posted which would seem to disable variable expansion. Indeed, you can test it on the command line:
vnix$ db2=echo
vnix$ a=`$db2 -x "select A from tablename where z in (select z from tablename Q where condition fetch first 1 rows only ) with ur"`
vnix$ c=`$db2 -x "select C from tablename W where R in ('$a') with ur"`
vnix$ set | grep ^c=
c='-x select C from tablename W where R in ('\''-x select A from tablename where z in (select z from tablename Q where condition fetch first 1 rows only ) with ur'\'') with ur'