Tomas,
Seems like you are asking for too much to write in a single command! I do not think it is possible to execute However, we can certainly write a shell script that satisfies your requirement, albeit with some modifications.
Code:
timestamp=`date '+%d%b%Y%H%M%S'`
sqlplus -S xxx/xxx@xxxxxxx @\tmp\2.sql > /tmp/result.txt
sqlplus_stat="$?"
if [[ ${sqlplus_stat} -eq 0 ]]; then
echo "${timestamp} Successful" > /tmp/log.txt
cp -p /tmp/result.txt /tmp/123.txt
else
echo "${timestamp} Failure" > /tmp/log.txt
cat /tmp/result.txt >> /tnp/log.txt
fi
HTH,
Regards,
Praveen