Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread
Message: 102750
BY: Lucas Maxwell (tism)
DATE: 2012-11-15 03:07
SUBJECT: When to free statements from execute

 

When using connection.execute the returned value is an instance of IBM_DB::Statement. This object appears to consume a handle with the DB2 server until it is freed. During normal flow doing the following too often can cause the server to run out of handles.

ActiveRecord::Base.connection.execute("SELECT * FROM SYSIBM.SYSDUMMY1")

That is unless

IBM_DB.free_stmt(result_of_execute_call)

is explicitly called.

I've done some digging around and execute is used by a lot of the adapter that expects it to return a statement that it then frees explicitly itself so freeing the statement and the handle. There doesn't appear to be a clear place when to free the statement, doing at the end of execute won't work as then fetch_data or result will fail, but doing it at the end of those methods doesn't always guarantee release.

Is it possible to release the statement from the server and still retain the data retrieved in a different way?


Thread View

Thread Author Date
When to free statements from executeLucas Maxwell2012-11-15 03:07
      RE: When to free statements from executePraveen Devarao2012-11-15 04:27
            RE: When to free statements from executeLucas Maxwell2012-11-15 04:57
                  RE: When to free statements from executePraveen Devarao2012-11-15 07:52
                        RE: When to free statements from executePraveen Devarao2012-11-15 07:54
                        RE: When to free statements from executeLucas Maxwell2012-11-16 01:04

Post a followup to this message