How to get SQL cursor code?

If I have a cursor and want to write cursor text at runtime, is it possible to use the cursor name in some way and get SQL?

For instance,

OPEN cursor_1 for SELECT ... 

I would like to believe that I can do something like cursor_1%NAME , since I can use other cursor attributes. ( % ISOPEN,% FOUND , etc.).

+4
source share
1 answer

AFAIK, there is no way to associate the cursor name with it, which is processed by SQL text, but by attaching V$open_cursor using v$sql using SQL_ID , you should be able to pull out and write information about the SQL expression being registered for open cursors.

 SELECT sql_id, user_name, sid, saddrsql_fulltext FROM v$sql join v$open_cursor USING (sql_id) 

Maybe you could match the SQL text with the cursor, but this should be a manual process

+4
source

All Articles