superbol-studio-oss icon indicating copy to clipboard operation
superbol-studio-oss copied to clipboard

Support COBOL variable uses in `EXEC SQL` blocks from the `DATA DIVISION`

Open nberth opened this issue 7 months ago • 3 comments

for the cursors, sure - but FL1 and FLD2 are indeed variables that are part of WORKING-STORAGE, even separate fields

           EXEC SQL BEGIN DECLARE SECTION END-EXEC.
      *
       01 DB                 PIC  X(010).
       01 FLD1               PIC  X(018).
       01 FLD2               PIC  X(026).
      * 
       01 MYTAB.
         03 MYKEY.
           05 FLD3           PIC  X(006).
           05 FLD4           PIC  X(008).
      *
         03 MYDATA.
            05 ...
      * 
           EXEC SQL VAR FLD3            IS CHAR      END-EXEC.
           EXEC SQL VAR FLD4            IS CHAR      END-EXEC.
      * 
           EXEC SQL END DECLARE SECTION END-EXEC.
           EXEC SQL INCLUDE SQLCA END-EXEC.
      *
           EXEC SQL AT :DBS
              DECLARE MYCUR CURSOR FOR
                 SELECT
                        FLD1, FLD2 FROM TAB
                 WHERE
                          TFL3
                       || TFL4
                 >=
                          :FLD3
                       || :FLD4
                 ORDER BY
                          TFL3
                       || TFL4
                 ASC
           END-EXEC.

Originally posted by @GitMensch in https://github.com/OCamlPro/superbol-studio-oss/issues/375#issuecomment-2909789291

In the snippet above, FLD3 and FLD3 should be bound to their COBOL declarations.

nberth avatar May 26 '25 14:05 nberth

and some extra, if it isn't handled in the LSP yet: SQL EXEC INCLUDE copybook END-EXEC should parse the copybook like a normal copybook (in theory: with a possible separate setting for search directory, but using default configured copybook paths and extension should cover at least > 95%, likely more [you can just add extra paths and extensions at the end of the existing list])

GitMensch avatar May 26 '25 14:05 GitMensch

I've just recognized that "goto reference" does not work at all for these files and the outline is empty. Could it be that the LSP is now tripping over something (the extension output has nothing on that)?

GitMensch avatar May 28 '25 10:05 GitMensch

I've just recognized that "goto reference" does not work at all for these files and the outline is empty. Could it be that the LSP is now tripping over something (the extension output has nothing on that)?

Thanks for reporting again. Would you have time to gather a collection of "minimal" test files (even very artificial) for which the extension is not working? It may not support EXEC SQL in every place (in terms of the COBOL grammar) where they may be encountered in real life.

nberth avatar May 28 '25 12:05 nberth