EXEC SQL INCLUDE
I'd like to understand the use of EXEC SQL INCLUDE a bit better.
Can somebody explain (or point me to a good doc explanation)... what does EXEC SQL INCLUDE actually do and also what happens if host variables i.e. table layouts etc aren't declared inside one i.e. are just declared as regular working-storage items? Also does it matter if fields 'included' as it were, are not actually used with sql?
Do I need the special sqlda and sqlca includes or are they created automatically? If I do,can I copy the content into my own copybook? - ideally I'll have just one db related copybook that I can put it into the 100 or so programs I'm converting?
Should mfsqlmessagetext be 'included' ? Does it matter if it is or isn't?
Thanks in advance,
Linden Rowland - IT Consultant
IT Consultant to Tindle Newspaper Group
RE: EXEC SQL INCLUDE
EXEC SQL INCLUDE is actually the equivalent of a COPY statement. It will make available to the precompiler any source code within the copy file specified in the copybook.
For OpenESQL there is no restriction that host variables need to be within EXEC SQL INCLUDE statements or even within the EXEC SQL BEGIN DECLARE SECTION. You can define SQL host variables using standard COBOL PIC types or you can use SQL TYPEs.
Some preprocessors like Oracle's Pro*COBOL do require that you define host variables within a EXEC SQL BEGIN SECTION and END SECTION headers.
sqlca and sqlda are copybooks that reside in the Visual COBOL\cpylib folder. sqlca is the standard Communication Area and should be brought into every program that uses SQL as this is where error handling variables such as SQLCODE and SQLERRMC are defined. SQLDA is required if you are referencing fields within for using dynamic SQL
mfsqlmessagetext is a Micro Focus extension. If this field is defined then it will be used to store the full message text returned from the execution of a SQL statement. If this is not defined then the message text is only available within the sqlerrmc field and may be truncated because its max length is only 70 bytes and message may be longer.
49 SQLERRML PIC S9(4) COMP-5.
49 SQLERRMC PIC X(70).
You can find additional information on SQLCA here:
I would recommend that you do not copy the content of the SQLCA and SQLDA directly into a different copybook. If you wish to have any only one copybook to include then create a copybook that contains the EXEC SQL INCLUDE SQLCA END-EXEC statement itself. That way if the contents of SQLCA ever changes you will get the correct version.