che-che4z-lsp-for-cobol icon indicating copy to clipboard operation
che-che4z-lsp-for-cobol copied to clipboard

Add support for DB2 SQL standard language option STDSQL(YES)

Open Oxdeception opened this issue 3 years ago • 4 comments

DB2 programs written to use the DB2 SQL standard language option show invalid definition errors on uses of SQLCA records.

Describe the solution you'd like Option to set STDSQL(YES)

Additional information When using SQL standard language rules SQLCA does not need to included by the programmer; The corresponding fields are automatically generated by the precompiler.

When STDSQL(YES) is specified, the Db2 precompiler or coprocessor automatically generates an SQLCA that includes the variable name SQLCADE instead of SQLCODE and SQLSTAT instead of SQLSTATE.

Per DB2 documentation: https://www.ibm.com/docs/en/db2-for-zos/12?topic=sql-standard-language

Oxdeception avatar Jun 22 '21 14:06 Oxdeception

Hi,

Thank you for mentioning "STDSQL(YES)". We will add this compiler option in coming releases. But currently, we support enabling SQLCA without including it by programmer.
You only will write " EXEC SQL INCLUDE SQLDA END-EXEC." that is all.

E.g. in below code, programmer is not including SQLCA or SQLDA explicitly. Our application can provide you all language-features (hover-over, etc..) as like you are in DB2.
This also works for DATACOM server as well. You can configure it in VSCode as in below snapshot

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO-SQL.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       
           EXEC SQL INCLUDE SQLDA END-EXEC.
           EXEC SQL INCLUDE SQLCA END-EXEC.
           
       PROCEDURE DIVISION.
            INITIALIZE SQLCA.
            MOVE '00' TO  SQLCAID  OF   SQLCA.            
            MOVE 23 TO  SQLCODE  OF SQLCA.
            DISPLAY SQLCA.
            DISPLAY SQLCODE.
            MOVE 23 TO  SQLERRML   OF   SQLCA.
            MOVE 23 TO  RETURN-CODE.
            

      *    SQLDA
            MOVE 23 TO  SQLDABC   OF   SQLDA. 
            
           IF  SQLCODE = ZERO  THEN  DISPLAY  "SUCCESS" 
           ELSE DISPLAY "FAIL SQLCODE = " SQLCODE.


 

asatklichov avatar Jun 22 '21 14:06 asatklichov

sqlca-da-config

asatklichov avatar Jun 22 '21 14:06 asatklichov

The SQLCA that is included implicitly by using an EXEC SQL INCLUDE SQLCA END-EXEC is different than the one provided by STDSQL(YES), which uses SQLCADE instead of SQLCODE, and SQLSTAT instead of SQLSTATE. Using the include still results in errors whenever these fields are used.

Oxdeception avatar Jun 22 '21 15:06 Oxdeception

We are not supporting STDSQL(YES) case, will be implemented in next releases.

asatklichov avatar Jun 23 '21 07:06 asatklichov