This article explains how a COBOL batch main program without any Datacom SQL can call a COBOL subprogram executing Datacom SQL calls dynamically.
z/OS
Datacom SQL batch-only.
For the main program , use COBOL compiler option NODYNAM. Then link-edit as usual so with INCLUDE DBSU1PR , INCLUDE DBXHVPR, ENTRY BEGIN and code ENTRY 'DBMSCBL' in the main program source .
Then for PGMSUB with SQL calls , use the Cobol compiler option DYNAM . Do NOT use the INCLUDE for DBSU1PR nor DBXHVPR and use ENTRY PGMSUB .
Note that the SQL Precompiler option USRNTRY for PGMSUB should be NONE.