Hi Dhiraj,
not sure if this would help for your situation but did you see Ivan Milazzotti 's recent blog post "For All Entries, GTT and OPEN SQL"? I haven't yet had a chance to make use of such a global temporary table but perhaps it's worth a try for your scenario.
Cheers
Bärbel