IMS provides a way to issue SQL statements directly
in a COBOL application to access your IMS data. IMS uses the same SQL coding techniques as Db2 for z/OS® when programming IMS SQL for COBOL.
Procedure
To include a SQL statement in an application program:
-
Choose one of the following methods for communicating with IMS:
- Embedded dynamic SQL
- JDBC application support
If you are writing your applications in Java™, you can
use JDBC application support to access IMS.
If you are
writing your applications for COBOL, use embedded dynamic SQL.
-
Define an SQL communications area (SQLIMSCA) that for your COBOL program can use to check
whether an SQL statement executed successfully.
-
Define at least one SQL descriptor area (SQLIMSDA).
-
Declare any of the following data items for passing data between IMS and COBOL:
- host variables
- host structures
Ensure that you use the appropriate data types.
-
Code SQL statements to access IMS data.
If you are using a SELECT statement to query IMS data,
use cursors to select a set of rows and then process one row at a time.
-
Check the execution of the SQL statements.
-
Handle any SQL error codes.