Db2 – Overview of leaked/unclosed cursors/statements on DB2 LUW server

cursorsdb2db2-luw

We're encountering a "too many open cursors issue" on DB2/LUW.

Is there any way to get a (database-server-side) list of the corresponding SELECT statements related to these open cursors?

We're doing that on Oracle all the time.

I know we could review the application logic but that is an awful lot harder in our particular case. So I wanted to get this question out first. Thanks.

Best Answer

SELECT 
  application_handle
, uow_id, activity_id, activity_type, activity_state
, timestampdiff(2, char(current timestamp - entry_time)) elapsed_sec
, stmt_text
FROM TABLE(MON_GET_ACTIVITY(null, -2))
order by elapsed_sec desc;

MON_GET_ACTIVITY table function - Return a list of activities