Skip to Main Content
  • Questions
  • Oralce Open v$open_cursor counts simple "updates" as open with the use of a cursor (open, execute, fetch, close, commit)

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Michael.

Asked: April 18, 2018 - 3:21 pm UTC

Last updated: April 19, 2018 - 10:17 am UTC

Version: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

Viewed 1000+ times

You Asked

I am checking for open cursors while running our client server application (application info below) with the query below and noticed that a simple “update” without the use of any cursors shows as open cursor. When another “update” is issued its replaced with the last update statement as in the example below.

Question: Does this update count again the open cursor count and eventually could lead to ORA-01000: maximum open cursors exceeded?

Thank you
Michael

Example (commits are done after each):
1.) Issue this below and shows as open cursor
update party p    set p.party_order_number = :1    where p.party_id = :2


2.) Issue this update and the update from 1. is gone from the open cursor list but 2 shows as open cursor:
update person_name ps    set ps.prefix = :1 ,   ps.first = :2 ,   ps.middle = :3 ,   ps.last = :4 ,   ps.seniority = :5 ,   ps.suffix = :6 ,   ps.no_first_name_flag = :7     where ps.name_id = :8


--application info:
--PowerBuilder .NET application
--Oracle 12c instance client
--Embedded SQL for the example above

--open cursor query:
select vop.sid,
       vsql.sql_text,
       vsql.sql_fulltext,
       count(vop.sid) over(partition by vop.sid) as countit,
       count(vop.sql_text) over(partition by vop.sid, s.osuser, vop.sql_text) as countit,
       vop.user_name,
       s.osuser,
       s.machine,
       vsql.module,
       s.status,
       s.lockwait,
       vop.cursor_type,
       to_char(s.logon_time,
               'DD-MM-YY HH24:MI:SS') in_time,
       s.last_call_et,
       vop.address,
       vsql.address,
       vsql.parsing_user_id,
       s.user#,
       vsql.*
  from v$open_cursor vop
  join v$sesstat a
    on vop.sid = a.sid
  join v$statname b
    on a.statistic# = b.statistic#
  join v$session s
    on a.sid = s.sid
  left outer join v$sql vsql
    on vop.address = vsql.address
 where b.name = 'opened cursors current'
   and s.username in ('APPLICATION_USER_ORACLE_DB')
   and vsql.module = 'APPLICATION.exe'
 and s.osuser = 'MYOSUSERNAME'
 order by vop.sid, vop.sql_text, s.osuser

and Chris said...

All DML statements are cursors! Select, insert, update, delete and merge.

So yes, these count towards your open cursor count.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

open cursor question is answered

Michael Wiegele, April 19, 2018 - 10:25 am UTC

Thank you Chris!
You answered my question and very much appreciate your help!
Michael

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.