Skip to content
Advertisement

Using CURSOR expression in WITH Clause in query Oracle 12.1

I have a strange issue where the data showing up in Cursor is incorrect. Below is the table and the query. But when I replace the CURSOR (Select * from H) with CURSOR( actual query of H ) , it works

Output of above query give Cnt = 3 and cursor has data as below which is incorrect. But when you just run Select * from H , you get the correct output i.e. 3, 4, 5 rows

Advertisement

Answer

As per this article Subquery refactoring either uses a global temporary table or an inline view.

In your case, it may be using a global temporary table and I guess the CURSOR keyword does something implicit with the global temporary table.

Try using the INLINE hint and see if it works

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement