In PL/SQL, I can use a trick like this one here to find out name/value pairs for every column in a row from a REF CURSOR:
TO_CHAR of an Oracle PL/SQL TABLE type
That’s an awesome trick. But it doesn’t work when the REF CURSOR is empty, such as this one here (that’s just an example. The real cursor doesn’t select from DUAL):
OPEN cursor FOR SELECT 1 FROM DUAL WHERE 1 = 0;
Does an empty REF CURSOR even have column name/type information?
Yes, I’ve tried that solution without rows, and you’re right.
From my limited point of view, I think here we need two different methods to retrieve columns’ names and values.
1) Dbms_sql package to retrieve the columns’ names.
2) The tbone method to retrieve the data.
Procedure
Test
Result