Using SQL statements in your application
You can code SQL statements in a COBOL program using dynamic SQL.
Dynamic SQL
Dynamic SQL statements are prepared and executed while the program is running. Use dynamic SQL when you do not know what SQL statements your application needs to execute before run time.
Dynamically executing SQL for fixed-list SELECT statements
A fixed-list SELECT statement returns rows that contain a known number of values of a known type. When you use this type of statement, you can specify a list of host variables to contains the filed values.
Dynamically executing SQL for varying-list SELECT statements
A varying-list SELECT statement returns rows that contain an unknown number of values of unknown type. When you use this type of statement, you do not know in advance exactly what kinds of host variables you need to declare for storing the results.
Dynamically executing SQL for non-SELECT statements
The easiest way to use dynamic SQL is to use non-SELECT statements such as the INSERT, UPDATE, or DELETE statement.
Dynamically executing a SELECT SQL statement with parameter markers
Use the SELECT statements with parameter markers.
Dynamically executing a non-select SQL statement with parameter markers
Use PREPARE and EXECUTE for non-SELECT statements like INSERT, UPDATE, and DELETE with parameter markers.
Parent topic:
Coding SQL statements in application programs: General information
Related concepts
SQL statements in COBOL programs