mridoni / gixsql

GixSQL is an ESQL preprocessor and a series of runtime libraries to enable GnuCOBOL to access PostgreSQL, ODBC, MySQL, Oracle and SQLite databases.
GNU General Public License v3.0
16 stars 8 forks source link

When pre compiling Gnu against PostgreSQL it cuts the SQL sentence #190

Open P1c4C0d3 opened 1 month ago

P1c4C0d3 commented 1 month ago

Basically the issue is that the precompiler created a different SQL statement from the source one truncating it.

This is the source SQL:

           EXEC SQL
R10        SELECT COUNT(*)
              INTO
R10             :GCMS-RATE-HST
              FROM GCMS_EXCHANGE_RATE G
              WHERE G.CURRENCY_CODE = :MONEDA-HST AND
                    G.DATE_FROM     = :YESTERDAY-DATE-HST
           END-EXEC.

Below is converted SQL statement:

       SET-GCMS-EX-RATES.
R10        MOVE ZEROES TO GCMS-RATE-HST.
GIXSQL*    EXEC SQL
GIXSQL*     SELECT COUNT(*)
GIXSQL*       INTO
GIXSQL*         :GCMS-RATE-HST
GIXSQL*       FROM GCMS_EXCHANGE_RATE G
GIXSQL*       WHERE G.CURRENCY_CODE = :MONEDA-HST AND
GIXSQL*             G.DATE_FROM     = :YESTERDAY-DATE-HST
GIXSQL*    END-EXEC.
GIXSQL     CALL STATIC "GIXSQLStartSQL"
GIXSQL     END-CALL
GIXSQL     CALL STATIC "GIXSQLSetResultParams" USING
GIXSQL         BY VALUE 9
GIXSQL         BY VALUE 3
GIXSQL         BY VALUE 0
GIXSQL         BY VALUE 0
GIXSQL         BY REFERENCE GCMS-RATE-HST
GIXSQL     END-CALL
GIXSQL     CALL STATIC "GIXSQLSetResultParams" USING
GIXSQL         BY VALUE 9
GIXSQL         BY VALUE 3
GIXSQL         BY VALUE 0
GIXSQL         BY VALUE 0
GIXSQL         BY REFERENCE MONEDA-HST
GIXSQL     END-CALL
GIXSQL     CALL STATIC "GIXSQLSetResultParams" USING
GIXSQL         BY VALUE 9
GIXSQL         BY VALUE 8
GIXSQL         BY VALUE 0
GIXSQL         BY VALUE 0
GIXSQL         BY REFERENCE YESTERDAY-DATE-HST
GIXSQL     END-CALL
GIXSQL     CALL STATIC "GIXSQLExecSelectIntoOne" USING
GIXSQL         BY REFERENCE SQLCA
GIXSQL         BY REFERENCE x"00"
GIXSQL         BY VALUE 0
GIXSQL         BY REFERENCE SQ0012
GIXSQL         BY VALUE 0
GIXSQL         BY VALUE 3
GIXSQL     END-CALL
GIXSQL     CALL STATIC "GIXSQLEndSQL"
GIXSQL     END-CALL.
           IF SQLCODE < 0
              DISPLAY "MQPCS115  - SET-GCMS-EX-RATES - 01"
              DISPLAY "SQLCODE : " SQLCODE
              DISPLAY "SQLSTATE: " SQLSTATE
              DISPLAY "SQLERRM: " SQLERRM
              DISPLAY "CURRENCY CODE.: " MONEDA-HST
              DISPLAY "DATE.: " YESTERDAY-DATE-HST
              PERFORM EJECUTE-ROLL-BACK-AND-STOP-RUN
           ELSE
R10           IF GCMS-RATE-HST = 0
R13              DISPLAY "NO GCMS EXCHANGE RATE FOUND FOR CURRENCY : "
R13                       MONEDA-HST
R13   *          PERFORM GET-LAST-GCMS-EX-RATE
              ELSE
                 PERFORM INSERT-NEW-GCMS-EX-RATE
              END-IF
           END-IF.
       EXIT.

And this is the generated SQL string:

GIXSQL 01  SQ0012.
GIXSQL     02  FILLER PIC X(0017) VALUE "SELECT COUNT( * )".
GIXSQL     02  FILLER PIC X(1) VALUE X"00".

We are testing gixsql 1.20

    testprogram

    CMS VERSION 6.00 MQPCS115 RELEASE.: 00014

    -V

    calling set-connection...

    ERROR: Environment variable SURCARD_ROOT not defined. Please check it.

    pgsql://ip_address:5432/davn_9_03_00_X?autocommit=off                                                                          

    MQPCS115 - ADVANCING SYSTEM's DATE 1 DAY FORWARD

    ------------------------------------------------

    OLD DATES:

        System Date  : +20240909

        Business Date: +20240909

    DECLARING CURSOR.

    SQLCODE CUR : +0000000000

    SQLSTATE CUR: 00000

    MQPCS115  - SET-GCMS-EX-RATES - 01

    SQLCODE : -0000000121

    SQLSTATE: 42886

    SQLERRM: Field count mismatch

    CURRENCY CODE.: +004

    DATE.: +20240909

    The program concludes with error

    Processed lines 000000000

    Start time      10:39:14:83

    Finish time     10:39:14:84

    testprogram

    CMS VERSION 6.00 MQPCS115 RELEASE.: 00014

    -V

    calling set-connection...

    ERROR: Environment variable SURCARD_ROOT not defined. Please check it.

    pgsql://ip_address:5432/davn_9_03_00_X?autocommit=off                                                                            

Pco program is the origin an testprogram.cbl is the result of gitsql.

We are compiling with gnucobol 3.2

Any suggestion what could be causing this issue, any workarround?

Thanks, Pablo

P1c4C0d3 commented 2 weeks ago

@mridoni can you help us with this issue? We appreciate it.