| 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? | |