Hi Linden,
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.
05 SQLERRM.
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.