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

The end of the "WORKING-STORAGE SECTION" is not recognized correctly. #160

Closed MrT201509 closed 1 year ago

MrT201509 commented 1 year ago

Hello again. Given is the following program code:

IDENTIFICATION DIVISION. PROGRAM-ID. testwss. DATA DIVISION. WORKING-STORAGE SECTION. 01 x PIC X(1) VALUE "x". PROCEDURE DIVISION. DISPLAY x.

Compiler reports build-error:

TEST_WSS.cbsql(16): error: 'x' cannot be used here

Adding a new line at the end of the "WORKING-STORAGE SECTION" (with or without a comment or a definition of another variable) solves the problem:

IDENTIFICATION DIVISION. PROGRAM-ID. testwss. DATA DIVISION. WORKING-STORAGE SECTION. 01 x PIC X(1) VALUE "x".

PROCEDURE DIVISION. DISPLAY x.

This is very confusing!

GitMensch commented 1 year ago

That comes from the used compiler, not from the IDE. Please create an issue at https://sourceforge.net/p/gnucobol/bugs/ including the version of the computer used.

MrT201509 commented 1 year ago

I created an issue on GitHub Pages.

mridoni commented 1 year ago

If you are using Gix-IDE and you are precompiling with GixSQL ("Precompile for ESQL" option enabled in the Properties window), this might - I cannot test it right now - be related to the fact that GixSQL does not behave well (meaning "at all") with lowercase variables and statements.

Could you please try to do one (or both) of these things?

1) disable ESQL precompilation in "Properties" (if not needed, obviously) 2) Make the "x" variable uppercase

Thanks

MrT201509 commented 1 year ago

That's it! Thank you!

Solution tested: disable ESQL precompilation in "Properties". Build is now successful.

"Make the 'x' variable uppercase" doesn't fix the problem.

GitMensch commented 1 year ago

Obviously GixSQL currently drops the last line before PROCEDURE DIVISION:

       DATA DIVISION.
       WORKING-STORAGE SECTION.
GIXSQL*01 X PIC X(1) VALUE "x".
GIXSQL*   ESQL CURSOR INIT FLAGS (START)
GIXSQL*   ESQL CURSOR INIT FLAGS (END)
       PROCEDURE DIVISION.
       DISPLAY X.

GIXSQL*
GIXSQL*   ESQL CURSOR DECLARATIONS (START)
GIXSQL     GO TO GIX-SKIP-CRSR-INIT.
GIXSQL GIX-SKIP-CRSR-INIT.
GIXSQL*
GIXSQL*   ESQL CURSOR DECLARATIONS (END)

allowing the COBOL compiler only to say that it has no clue about X in this last line. I guess that's an easy for @mridoni.

mridoni commented 1 year ago

I moved the issue here since it is actually a GixSQL issue

MrT201509 commented 1 year ago

Thank you for helping. I close the issue now.

GitMensch commented 1 year ago

Please reopen - the issue is a severe problem in gixpp which isn't fixed.

mridoni commented 1 year ago

Fixed by dd9050ec0464a993cd2a4bbf4aee431b06c0bfd8. BTW: the same problem happened in the LINKAGE section, it was also fixed there.