need help in search the error messages from log file

Hi,

My log file has error messages, universal no and universal ID. The problem is i have to search Universal ID from the error messages. But the log file write error messages with universal no and error messages in one line. and universal no with universal ID in other line. So i write two loops for to grab the universal ID. First grep all universal no in one go. But for Universal ID i have to run grep command for each universal no. I am using grep -m 1 option also to out from the log once i found the pattern. But issue is every time it will start the searching from starting. So there is any way that i start search when i left.
and server write random thing between the lines. So i can't use -B option grep.

Try:

awk '/FATAL/{id=$NF}$1==id{print $3}' file

-- deleted ---

---Updated below---

 
$ nawk '$0~/FATAL/{b=$NF}{if($0~b && b!~$NF){print $NF}}' log.txt
apple
rat
orange.

Hi thanks for reply but here the my problem. my log files actually look like.

2012:02:23:08:53:06.667 el8 3:INFO SERVER NOFMT 33001598665301 REQUEST_RECEIVED_FROM_MERCHANT kulula_dm
//random messages
2012:02:23:08:53:16.936 el8 1:ERR1 VELOCITY 33001598665301 Failed to query velocity server: java.net.SocketTimeoutException: Read timed out

..
so here "failed to query velocity server" is my error message and i have to give final result as "kulula_dm" as my final out put.

This log files is zipped.