On Sun, Jan 30, 2022 at 1:47 AM Dylan Camilleri <dcam...@gmail.com> wrote:
> Hi, > > Want to add some notes. Did some further reading on the issue. If a jdbc > callable statement is started on a jdbc connection object. > > Say: cs = Conn.prepareCall() > > Then it must be put into a begin / end block and under ensure part do > "cs.close" > > Begin > > cs = Conn.prepareCall("some procedure"); > > cs.executeQuery > > Ensure > > cs.close > > End > > This makes sure that the cursor is released on oracle side. > > Tested this and have reduced the open_cursors parameter in oracle from > 1000 to 100 and it works fine. > Sequel only uses prepareCall in one place, and it does use a begin/ensure to try to ensure it gets closed, but maybe the logic can be improved: diff --git a/lib/sequel/adapters/jdbc.rb b/lib/sequel/adapters/jdbc.rb index adf474994..138990dfc 100644 --- a/lib/sequel/adapters/jdbc.rb +++ b/lib/sequel/adapters/jdbc.rb @@ -188,12 +188,12 @@ module Sequel args = opts[:args] || [] sql = "{call #{name}(#{args.map{'?'}.join(',')})}" synchronize(opts[:server]) do |conn| - cps = conn.prepareCall(sql) + begin + cps = conn.prepareCall(sql) - i = 0 - args.each{|arg| set_ps_arg(cps, arg, i+=1)} + i = 0 + args.each{|arg| set_ps_arg(cps, arg, i+=1)} - begin if defined?(yield) yield log_connection_yield(sql, conn){cps.executeQuery} else @@ -205,7 +205,7 @@ module Sequel rescue *DATABASE_ERROR_CLASSES => e raise_error(e) ensure - cps.close + cps.close if cps end end end Are you calling prepareCall manually? Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to sequel-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/CADGZSSe3k%2Bqq0W-GTivtOnCNCt7VqJ39MhY%2BZyj-Z1kJRHYDsg%40mail.gmail.com.