I have a java stored procedure where I often run into the following error: SQL0519N The PREPARE statement identifies the SELECT or VALUES statement of the open cursor "SQLCUR381"
when I execute certain statements.
I have been able to solve the problem in certain cases by using "trial and error" tactics, but in some cases I can not determine the cause of the error. I am absolutely sure that all resultsets of the statements I use are closed before I execute the statement again (I must have checked it about 20 times by now).
I will not post any code. I have done that a week ago, but did not get any answers on my question. The code is way to long and complex and it would take too much time to dive into it.
I can hardly believe that I am the only one running into this problem. So
what I am looking for is a theoritical answer to my questions:
*) what can be the cause of this SQL0519N error?
*) what limitations do I have to take into account when working with java stored procedures?
*) can I use nested statements on the same table, that is can I loop through a resultset on table X and perform another query on table X from within that loop?
I'm finally out of it. I was using two objects (O1 and O2), each retrieving its own connection object through the DriverManager (with url "jdbc:default:connection").
Since all calls to O2 were coming from O1, I passed the connection of O1 to O2 instead of having O2 create its own connection. And gone were all the mysterious errors.