| kprasann 2004-08-30, 8:55 pm |
| Thanks.
Yes, I do understand the INCLUDE being resolved by pre-compiler and COPY
being resolved by the compiler. But, in manframes, host-variables that are
outside of INCLUDEs(say variables under working storage) just works fine
and the pre-compiler doesn't flag any messages for this.
According to igyapg00.pdf COBOL for AIX Programming Guide Version 2.0,
"You can identify host variables used on SQL statements without using EXEC
SQL BEGIN DECLARE SECTION and EXEC SQL END DECLARE SECTION statements"
But I'm not able to pass thru pre-compilation without using them for the
host variables. Is that begin declare/end declare mandatory then?
sample code that I tried to compile:
IDENTIFICATION DIVISION.
PROGRAM-ID. "TESTSQL".
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
*EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 WS-OPT PIC S9(9) COMP-5.
01 WS-NAME.
49 WS-NAME-LEN PIC S9(4) COMP-5.
49 WS-NAME-DATA PIC X(128).
*EXEC SQL END DECLARE SECTION END-EXEC.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
PROCEDURE DIVISION.
0000-MAIN SECTION.
DISPLAY 'START'.
MOVE 'FILEPGM' TO WS-NAME.
EXEC SQL
SELECT QUERYOPT INTO :WS-OPT FROM SYSIBM.SYSPLAN
WHERE NAME = :WS-NAME
FETCH FIRST 1 ROWS ONLY
END-EXEC.
DISPLAY 'SQLCODE=' SQLCODE.
DISPLAY 'OPT= ' WS-OPT.
DISPLAY 'STOP'.
STOP RUN.
0000-EXIT.
EXIT.
Error message(when not using the begin declare/end declare for a host
variable in working storage):
LINE MESSAGES FOR testsql.sqb
-----------------------------------------------------------
SQL0060W The "COBOL" precompiler is in progress.
24 SQL4942N The statement selects an incompatible data type into
host variable ":WS-OPT". SQLSTATE=42806
SQL0095N No bind file was created because of previous errors.
SQL0091W Precompilation or binding was ended with "2" errors and
"0" warnings.
When the exec sql begin/end declare is used, the (pre)compilation is fine
and the program executes successfully.
Any hints would be helpful.thanks!
|