Skip to main content

I am involved in an assessment of migrating an application from using SYBASE provided SQL Preprocessor to OpenESQL.  I have created a simple test program and I have found an issue.  

With the SYBASE preprocessor, we can so EXEC SQL Select cola, colb into :ws-a, :ws-b from tablex where colc = 'something' end-exec. Where ws-a and ws-b are arrays and many rows are returned.

With OpenESQL, we appear to need to add a clause FOR :ws-max to this statement or else it only returns one row.

Am I correct, or am I missing something?

 

I have attached a sample program, see line 39.

 

The file attach does not seem to be working.

 

Environment:

Server Express 5.1.14 on Linux
Database is SYBASE ASE 15.7, with SYBASE ODBC Driver (also 15.7).

I am involved in an assessment of migrating an application from using SYBASE provided SQL Preprocessor to OpenESQL.  I have created a simple test program and I have found an issue.  

With the SYBASE preprocessor, we can so EXEC SQL Select cola, colb into :ws-a, :ws-b from tablex where colc = 'something' end-exec. Where ws-a and ws-b are arrays and many rows are returned.

With OpenESQL, we appear to need to add a clause FOR :ws-max to this statement or else it only returns one row.

Am I correct, or am I missing something?

 

I have attached a sample program, see line 39.

 

The file attach does not seem to be working.

 

Environment:

Server Express 5.1.14 on Linux
Database is SYBASE ASE 15.7, with SYBASE ODBC Driver (also 15.7).

The FOR should not be required. If you do not have the FOR specified then it will return the number of elements in the arrays or the number of elements in the table whichever is smaller.

I did not have a Sybase system to test with but I tested with Oracle and the following worked fine and returned all 10 elements.

 

      $SET SQL(DBMAN=ODBC)  sourceformat(variable) 
       WORKING-STORAGE SECTION. 
       EXEC SQL INCLUDE SQLCA  END-EXEC. 
       01  DCLEMP.
           03 EMP-EMPNO      PIC S9(4)  COMP-3 occurs 10 times.
           03 EMP-ENAME      PIC X(10)  occurs 10 times.
           03 EMP-JOB        PIC X(9)   occurs 10 times.
       01 sub1               pic 9(3)   value 0.
       PROCEDURE DIVISION.

           EXEC SQL 
              CONNECT 'SCOTT' identified by 'tiger' using 'testora32' 
           END-EXEC 
         
           EXEC SQL 
              SELECT 
                 A.EMPNO
                ,A.ENAME
                ,A.JOB
              INTO 
                :EMP-EMPNO
               ,:EMP-ENAME
               ,:EMP-JOB
             FROM SCOTT.EMP A
           END-EXEC 
           perform varying sub1 from 1 by 1 until sub1 > 10
              display EMP-ENAME(sub1)
           end-perform
           EXEC SQL DISCONNECT CURRENT END-EXEC 
           STOP RUN.