Hi Suvetha,
Since an ORA error code is given, you can be certain that the error is coming from the (Oracle) database, and that it's not an OutSystems problem. If you Google on that error, you'll find countless troubleshooting tips and tricks.
Personally I'd break down this monstrosity of a query, and see if each individual part runs as expected, before trying it all together.