SQL

Use the SQL compiler option to enable the Db2® coprocessor and to specify Db2 suboptions. You must specify the SQL option if a COBOL source program contains SQL statements (EXEC SQL statements) and the program has not been processed by the Db2 precompiler.

SQL option syntax

Read syntax diagramSkip visual syntax diagramNOSQLSQL(" DB2-suboption-string")

Default is: NOSQL

Abbreviations are: None

When you use the SQL option, the Db2 coprocessor writes the database request module (DBRM) to ddname DBRMLIB. Db2 must be available on the machine on which you compile.

If you specify the NOSQL option, any SQL statements found in the source program are diagnosed and discarded.

Use either quotation marks or apostrophes to delimit the string of Db2 suboptions.

You can partition a long suboption string into multiple suboption strings in multiple CBL statements. For example:


//STEP1 EXEC IGYWC, . . .
// PARM.COBOL='SQL("string1")'
//COBOL.SYSIN DD *
       CBL SQL("string2")
       CBL SQL('string3')
       IDENTIFICATION DIVISION.
       PROGRAM-ID. DRIVER1.
       . . .

The Db2 suboptions are concatenated in the order of their appearance. Thus in the example above, the compiler passes the following suboption string to the Db2 coprocessor:


"string1 string2 string3"

The concatenated strings are delimited with single spaces as shown. If multiple instances of the same Db2 option are found, the last specification of each option prevails. The compiler limits the length of the concatenated Db2 suboption string to 4 KB.

related references  
Conflicting compiler options