waliwali / ibm-db

Automatically exported from code.google.com/p/ibm-db
0 stars 0 forks source link

Problem with opening more than one DB #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Running the program below will open MYDB1, run a query on the DB, and close 
it. Then it will open MYDB2, and run a query on it.
2. No rows can be fetched from that query.

What is the expected output? What do you see instead?
The expected output is nothing in this case. What I get is an exception:

Traceback (most recent call last):
  File "C:\temp\test.py", line 13, in <module>
    ibm_db.fetch_tuple(statement)
Exception: Column information cannot be retrieved:

What version of the product are you using? On what operating system?
This is ibm-db 2.0.0 on DB2 Express-C 9.7.5 on Windows XP SP3.

Please provide any additional information below.

This is the program:

import ibm_db

db = ibm_db.connect('MYDB1', '', '')
statement = ibm_db.exec_immediate(db, 'select * from mytab1')
while 1:
  t = ibm_db.fetch_tuple(statement)
  if not t:
    break
ibm_db.free_stmt(statement)
ibm_db.close(db) #(1)
db = ibm_db.connect('MYDB2', '', '')
statement = ibm_db.exec_immediate(db, 'select * from mytab2')
ibm_db.fetch_tuple(statement)
ibm_db.free_stmt(statement)
ibm_db.close(db)

Additional note: When I comment out the line marked with (1), producing a 
dangling database connection, then the exception does not occur.

Original issue reported on code.google.com by axel.nie...@web.de on 30 Oct 2012 at 8:34

GoogleCodeExporter commented 9 years ago
Thanks for reporting this issue, we are able to reproduce this issue and 
working to resolve it. 

There is one work around for this issue you can use it for temporary resolution
Free out the statement variable after "ibm_db.free_stmt(statement)" line by 
"del statement".

Please let me know how the above workaround works for you. I will update you 
once we get the resolution of the above problem.

Thanks,
Rahul

Original comment by rahul.pr...@in.ibm.com on 30 Oct 2012 at 10:18

GoogleCodeExporter commented 9 years ago
Thank you for the workaround using del. That works.

Original comment by axel.nie...@web.de on 30 Oct 2012 at 10:46

GoogleCodeExporter commented 9 years ago
This issue has been fixed in ibm_db-2.0.1.

Original comment by rahul.pr...@in.ibm.com on 1 Mar 2013 at 10:07