My problem is ...
I take the ref cursor, and have added some more data in there, based on a few conditions from different tables. So my ref cursor actually has more relevant data as compared to its source. I now need to find a way to sort that info. Is there a way around this?
I take the ref cursor, and have added some more data in there
What do you mean ? You can't add data through a cursor (or it is something I am not aware of), you have to insert data into your table(s) with INSERT statements or update data with UPDATE statements on your table(s), but not directly on the cursor. AFAIK, cursors in Oracle are read-only... Furthermore, Your cursor is related to a SELECT query that reads data as they were at the point in time the execution of the query began (this is part of the read-consistency mechanism of Oracle), so AFAIK you can only read these "old data" with your cursor unless you re-execute your query after your inserts or updates. BTW, maybe you only need insert or update queries in a first time (no select), and when you're done, select the new data. What do you think ?
To sankarg :
Your solution would not work because of what I said above : karuna would still have to re-execute the query after the updates or inserts. Furthermore, be cautious about dynamic SQL without bind variables :
1) in PL/SQL, dynamic SQL in general is less optimized than static SQL
2) using concatenations like 'select ... from ... where '||where_clause is prone to sql injection (you can search the web for "sql injection" to learn more about that)
3) instead of using ||, use bind variables when you can, search on asktom about "bind variables" to learn more about their necessity in PLSQL (when using dynamic SQL) and even more in L3G like C, C++, VB, Java... And look at the proper doc (depending on your language) for more info on how to use them.