Subject Invalid cursor declaration Statement already has a cursor assigned
Author Bryan
Hi all,

I have an application (Delphi using IBExpress) which imports a file into a FB database.

Over the weekend I was soak/performance testing the import and had some strange results. Every time the import was attempted (120 attempts) the same file was used.

Upon analyzing the results I notices that 1 in 10 of the imports had failed with the error:

Dynamic SQL Error SQL error code = -502 Invalid cursor declaration Statement already has a cursor 19798598 assigned

The line number in the data file where this occurred was different every time.

Since I am using the same file every time and exercising the same code path in my application this has lead me to believe this may be a problem with the database or IBExpress. I would appreciate a little assistance in narrowing the problem down.

The file I am importing is 480MB and contains 6 million records. The whole file is imported with a single transaction, and each record has a save point wrapped around it. The save point can "rollback" if a detail record is found to have had an error, otherwise it is "committed". At the end of the import the transaction is committed and a database backup (no garbage collection) is triggered. No database admin was performed between imports. The import starts by deleting all the records previously imported.

I had modified the code to re-import the file 1 minute after importing it - this was for the benefit of the soak test.

I am using Firebird-2.5.0.26074_1_Win32.exe. Our customer has seen a similar problem using Firebird-2.0.5.13206_1_win32.exe.

The platform is WinXP Pro. The database is configured with 16K pages and 32000 buffers.

Please help.

Bryan