Feedback
Did this article resolve your question/issue?

   

Article

Error SQL0519N occurs on call to ExecuteReader() when connected to DB2 7VR3

Information

 
TitleError SQL0519N occurs on call to ExecuteReader() when connected to DB2 7VR3
URL Nameerror-sql0519n-occurs-on-call-to-executereader-when-connected-to-db2-7vr3
Article Number000120965
EnvironmentProduct: Connect for ADO.Net DB2 Provider
Version: 4.2
O/S: Windows
Database: DB2
Application: N/A
Question/Problem Description
Error SQL0519N occurs on call to ExecuteReader() when connected to DB2 7VR3
Steps to Reproduce
Clarifying Information
Occurs when running the following code :
try
{
    while (true)
    {
        using (DB2Connection connection = new DDTek.DB2.DB2Connection("Database Name=dbname;Host=localhost;Password=***;Persist Security Info=True;User ID=user; Pooling=true;port=9999"))
        {

            connection.Open();

            DB2Command cmd = new DB2Command("SELECT * FROM TABLE.INDEX2", connection);

            cmd.Transaction = connection.BeginTransaction();
            DB2DataReader reader = cmd.ExecuteReader();
        }
    }
}
catch (Exception ex)
{
    throw ex;
}
Error MessageSQL0519N
Defect Number77900
Enhancement Number
Cause
When a reader server is executed, it returns a result-set schema, but it is believed that the DB2 Server does not open the actual result-set cursor at this point.

It appears that only when a reader.Read() operation is performed, the cursor is opened on the server side. So, when an application closes the Reader the driver only sets the CloseQuery request to the server; only if the driver has processed the data in the result-set using Reader.Read(). 

So far, with versions of DB2 prior to DB2v7R3, this was working as server was still able to close the result-set. However, with DB2v7R3, it appears there has been a change in this behavior. 
Resolution
Planned to be addressed in version 4.3 since DB2 version 7VR3 is not supported with version 4.2 of the provider
Workaround
try 

    while (true) 
    { 
        using (DB2Connection connection = new DDTek.DB2.DB2Connection("Database=<Database Name>;Host=<Host Name>;User ID=<User Id>;Password=<Password>;Port=<Port>;Pooling=true;")) 
        { 
            connection.Open(); 
            DB2Command cmd = new DB2Command("SELECT * FROM SYSVIEWDEP", connection); 

             DB2DataReader reader = cmd.ExecuteReader(); 

// Add the line below to avoid SQL0519N error 
            while (reader.Read()) { } 
        } 
    } 

catch (Exception ex) 

    throw ex; 
Notes
Last Modified Date9/26/2017 8:17 PM
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.