My situation:
- I have a table named Table1. It has lots of columns, one of them is Column1. I don’t know the other columns, they may even change sometimes.
- There is a strongly typed ref cursor type which returns Table1%rowtype, named cur_Table1.
- I have a stored procedure named SP1 which has an out parameter of type cur_Table1. I’m calling this SP1 stored procedure from another database that only sees this stored procedure, but not the table or the type itself.
How do I select only Column1 from the returned cursor?
I know I can fetch into a record or as many variables as the cursor has columns, but I only know of one column’s existence so I can’t declare the complete record or correct number of variables.
You can do this with
DBMS_SQL, but it ain’t pretty.Table and sample data (COLUMN1 has the numbers 1 – 10):
Package with a procedure that opens a ref cursor and selects everything:
PL/SQL block that reads COLUMN1 data from the ref cursor: