This section covers the following topics:
To be able to access a DB2 table with a Natural program
Use the Natural Tools for DB2 to define a DB2 table.
Use Predict or the SQL Services function of the Natural SYSDDM utility to create a Natural DDM of the defined DB2 table.
Once you have defined a DDM for a DB2 table, you can access the data stored in this table by using a Natural program.
The Natural interface to DB2 translates the statements of a Natural program into SQL statements.
Natural automatically provides for the preparation and execution of each statement. In dynamic mode, a statement is only prepared once (if possible) and can then be executed several times. For this purpose, Natural internally maintains a table of all prepared statements (see Statement Table in Internal Handling of Dynamic Statements).
Almost the full range of possibilities offered by the Natural programming language can be used for the development of Natural applications which access DB2 tables. For a number of Natural DML statements, however, there are certain restrictions and differences as far as their use with DB2 is concerned; see Natural DML Statements as described in Statements and System Variables. In the Natural Statements documentation, you can find notes on Natural usage with DB2 attached to the descriptions of the statements concerned.
As there is no DB2 equivalent to Adabas ISNs (Internal Sequence Numbers), any Natural features which use ISNs are not available when accessing DB2 tables with Natural.
For SQL databases, in addition to the Natural DML statements, Natural provides SQL statements as described in Statements and System Variables. In the Natural Statements documentation you can find a detailed description of these statements.
Since Predict supports DB2, direct access to the DB2 catalog is possible via Predict and information from the DB2 catalog can be transferred to the Predict dictionary to be integrated with data definitions for other environments.
DB2 databases, tables and views can be incorporated and compared, new DB2 tables and views can be generated, and Natural DDMs can be generated and compared. All DB2-specific data types and the referential integrity of DB2 are supported. See the relevant Predict documentation for details.
In addition, the Predict active references support static SQL for DB2 as described in WITH XREF Option in Preparing Programs for Static Execution.
The message number ranges of Natural system messages related to DB2 are 3275 - 3286, 3700-3749, and 7386-7395.