title: Postgres - Finding an open cursor and closing it
body: <p>In <code>SQL Server</code> I used following SQL to find an open cursor and closing it in a 'catch' block.</p>
  
  <pre><code>IF EXISTS(SELECT 1 FROM sys.dm_exec_cursors(@@SPID) WHERE [name] = 'Crsr_IDs' AND IS_OPEN = 1)
  BEGIN
      CLOSE Crsr_IDs
      DEALLOCATE Crsr_IDs
  END
  </code></pre>
  
  <p>In similar way how to find an open cursor in <code>Postgres</code> with specific name in EXCEPTION block and close it?</p>