Subject | Invalid cursor declaration Statement already has a cursor assigned |
---|---|
Author | Debora |
Post date | 2013-08-23T08:00Z |
Hello,
I'm currently writing a set of unit tests for our product CopyCat (cf. http://www.copycat.fr), in which I cycle through all our supported connector and perform a series of tests. Since we support IBObjects, I have been trying to get my tests to work with it, but I am getting a very strange error message when preparing a query : "Invalid cursor declaration Statement already has a cursor XXX assigned". I am of course not declaring any cursors or doing anything exotic, I am merely executing a series of SQL statements, and strangely, it doesn't always bomb out on the same query...
The code is too long to post here, but what I'm doing is basically :
- Creating an instance of a TDataModule descendant containing a CopyCat IBO connector. Interally, this connector creates an instances of TIB_Connection and TIB_Transaction, and one instance of TIBOQuery for every query.
- I then automatically create a new database (using TIB_Connection.CreateDatabase).
- I create a table called TEST.
- I create the CopyCat replication tables and triggers.
- I insert some data.
- I replicate using CopyCat (to another database created the same way).
- I then check to see if the data has been correctly replicated.
In most cases, it fails while creating the replication triggers. But it's not always the same place, and if I put a break-point and step through it, it usually works!
One thing is that since my SQL is dynamically created, I use the same TIBOQuery object many times. I simply Close, UnPrepare, change the SQL, and Open again. So it could be that TIBOQuery is creating a cursor at some point and it doesn't get freed correctly when unprepared, or something like that...
So my question is two-fold :
1) Do you have any idea what I might be doing wrong ?
2) If not, do you have any idea what I might do differently to work around this problem. I suspect that I don't need the cursor that IBO is creating anyway (I need a very simple, readonly, unidirectional SQL query object with no frills), so maybe there are options I can disable so as to work around this problem. I know I could use TIB_Query instead (in fact, I used to do so), but TIBOQuery allows me to get the field values as a simple Variant (and let IBO figure out how to make that Variant) whereas with TIB_Query I had to do it all by hand, and it was causing some problems with certain data-types (can't remember which).
FWIW, I'm using a fresh download of the latest IBO (evaluation) version, in Delphi XE2.
Thanks in advance for your help.
Regards,
Jonathan Neve.
I'm currently writing a set of unit tests for our product CopyCat (cf. http://www.copycat.fr), in which I cycle through all our supported connector and perform a series of tests. Since we support IBObjects, I have been trying to get my tests to work with it, but I am getting a very strange error message when preparing a query : "Invalid cursor declaration Statement already has a cursor XXX assigned". I am of course not declaring any cursors or doing anything exotic, I am merely executing a series of SQL statements, and strangely, it doesn't always bomb out on the same query...
The code is too long to post here, but what I'm doing is basically :
- Creating an instance of a TDataModule descendant containing a CopyCat IBO connector. Interally, this connector creates an instances of TIB_Connection and TIB_Transaction, and one instance of TIBOQuery for every query.
- I then automatically create a new database (using TIB_Connection.CreateDatabase).
- I create a table called TEST.
- I create the CopyCat replication tables and triggers.
- I insert some data.
- I replicate using CopyCat (to another database created the same way).
- I then check to see if the data has been correctly replicated.
In most cases, it fails while creating the replication triggers. But it's not always the same place, and if I put a break-point and step through it, it usually works!
One thing is that since my SQL is dynamically created, I use the same TIBOQuery object many times. I simply Close, UnPrepare, change the SQL, and Open again. So it could be that TIBOQuery is creating a cursor at some point and it doesn't get freed correctly when unprepared, or something like that...
So my question is two-fold :
1) Do you have any idea what I might be doing wrong ?
2) If not, do you have any idea what I might do differently to work around this problem. I suspect that I don't need the cursor that IBO is creating anyway (I need a very simple, readonly, unidirectional SQL query object with no frills), so maybe there are options I can disable so as to work around this problem. I know I could use TIB_Query instead (in fact, I used to do so), but TIBOQuery allows me to get the field values as a simple Variant (and let IBO figure out how to make that Variant) whereas with TIB_Query I had to do it all by hand, and it was causing some problems with certain data-types (can't remember which).
FWIW, I'm using a fresh download of the latest IBO (evaluation) version, in Delphi XE2.
Thanks in advance for your help.
Regards,
Jonathan Neve.