EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
Expand all | Collapse all

sql prepare statement

Discussion Topic

Discussion TopicThu September 14, 2017 02:08 PM

  • 1.  sql prepare statement

    Posted Thu September 07, 2017 07:53 AM

    Hello to all,

     

    From a WEB Project at RBD 8.5 I try to execute a SQL statement using "prepare" (I want to build the SQL statement dynamic).

    Although I have done the same thing successful with DB2 Connection, when I switch to SQL Server Connection, I receive the following error:

    EGL0504E OPEN: SQL Server supports holdability at the connection level only. Use the connection.setHoldability() method.[sqlstate:00000][sqlcode:-99999]

    EGL0501E GET NEXT: result set RESULTSET not found[sqlstate:24501][sqlcode:-501]

     

    I tried to open the cursor "with hold" and I received for once again the same error.

     

    The query function looks like:

    function GetSpecRecs(SearchRec TechSupportRec[] out, WhereClause string in, SqlCode int out, SqlMsg string out)           TechRec TechSupportRec; //single record for table      searchRec = new TechSupportRec[0];           syslib.writeStdout("Step 1");                     try            prepare selectStatement from "SELECT ComCode, dwxpsymb, custcafm, onoma, custpatr, custdiey, custtawk, dwxpendt, dwxplhdt " + WhereClause;            onException (exception SQLException);                        SqlCode = exception.sqlcode;                        syslib.writeStdout("Sql RExc0:"+exception.message);                  onException (exAny AnyException);                        syslib.writeStdout("any RExc0:"+exAny.message);      end           i int = 1;           try //open the cursor                 open resultSet with selectStatement            into TechRec.ComCode, TechRec.Policy, TechRec.AFM,                  TechRec.FLName, TechRec.FatherName, TechRec.Address,                  TechRec.PostalCode, TechRec.IncDate, TechRec.ExpDate;                         syslib.writeStdout("Step 2");                                         // Position into the list according to the listSpec.position passed to this function                  // This causes a read of the first element.            onException (exception SQLException);                        SqlCode = exception.sqlcode;                        syslib.writeStdout("Sql RExc1:"+exception.message);            onException (exAny AnyException);                        syslib.writeStdout("any RExc1:"+exAny.message);      end           try                                         get next from resultSet ;                             onException (exception SQLException);                        SqlCode = exception.sqlcode;                        syslib.writeStdout("Sql RExc2:"+exception.message);            onException (exAny AnyException);                        syslib.writeStdout("any RExc2:"+exAny.message);      end                                // Get the rest      while (sysvar.sqlData.sqlcode == 0) //then loop through the rest of the rows            syslib.writeStdout("Step 3");            searchRec.appendElement(TechRec);        //                syslib.writeStdout("Rec1:"+AYRec.PolicyNo);            try                  get next from resultSet;                                              onException (exception SQLException);                        SqlCode = exception.sqlcode;                        syslib.writeStdout("Sql RExc3:"+exception.message);                  onException (exAny AnyException);                        syslib.writeStdout("any RExc3:"+exAny.message);            end                    end                 syslib.commit();                      end //of function

     

     

    michaeldefox


  • 2.  Re: sql prepare statement

    Posted Mon September 11, 2017 08:56 AM

    Hi Michael,

     

    I ended a project a short time ago using SQL Server with RBD V.9.5 and had no problems. Are you using which version of SQL Server JDBC Driver?

    I was looking at your sql statement in the prepare

    prepare selectStatement from "SELECT ComCode, dwxpsymb, custcafm, onoma, custpatr, custdiey, custtawk, dwxpendt, dwxplhdt " + WhereClause;
     but I did not see the from clause. Is it within WhereClause?

    important: SQL SERVER is case sensitive for column and table names.

     

    Regards

    Hsieh

    Hsieh


  • 3.  Re: sql prepare statement

    Posted Thu September 14, 2017 02:08 PM
     
    Thanks for your reply
     
    From clause is included in Where clause. The driver is Microsoft SQL Server JDBC Driver (XA)  6.1.0.15, do you think that I have to use a newer version or is something wrong with the prepare and the open cursor syntax ?
     
    Thank you in advance.
    michaeldefox


  • 4.  Re: sql prepare statement

    Posted Thu September 14, 2017 02:25 PM

    Michael,

     

    I have download "Microsoft JDBC Driver 4.0 for SQL Server" on the  link http://msdn.microsoft.com/data/jdbc

    Please could you try it.

     

    Regards

    Hsieh