In my personal experience, quite often I came across the need to test and optimize queries used by REF CURSORS. Sometimes it’s a really painless operation, other times it can really be a very long and complex operation that can make you waste a lot of time. Let’s see what we would normally do in a simple case: consider a procedure GET_DATA which returns a SYS_REFCURSOR
1 2 3 4 5 6 7 8 9 10 |
create or replace procedure get_data(pi_table_name in VARCHAR2, po_resultset out SYS_REFCURSOR) is begin open po_resultset for select atc.OWNER, atc.COLUMN_NAME, atc.DATA_TYPE from all_tab_columns atc where table_name = pi_table_name order by column_id; end get_data; / |
The query used for the ref cursor is quite simple, it extracts 3 columns and uses just one parameter as a filter. In such case, if I wanted to test the query, I would probably take it outside and run it manually to perform my test.