I am trying to write a function that should accept a query as a parameter and return all the bound columns in that query.

Function return_bound_cols(p_sql Varchar2) RETURN VARCHAR2

Example:

If the parameter p_sql=

'SELECT C1, C2
FROM T
WHERE C3 = :b3 AND C4=:b4 AND C5= 5';

The function should return the string: 'b_C3,b_C4'

so that I can later open a ref cusrsor 'USING b_C3,b_C4'.

The parameter queries are stored in a table, hence I have to generate 'USING b_C3,b_C4' dynamically.

No success so far, please help..