che-che4z-lsp-for-cobol
che-che4z-lsp-for-cobol copied to clipboard
Add support for DB2 SQL standard language option STDSQL(YES)
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
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.
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.
We are not supporting STDSQL(YES) case, will be implemented in next releases.