Accessing a DB2 Table

Start of instruction set To enable access to a DB2 table with a Natural program

  1. Use the Natural Tools for DB2 to define a DB2 table; see Using Natural Tools for DB2.

  2. Use Predict or the SQL Services function of the Natural SYSDDM utility to create a Natural data definition module (DDM) of the defined DB2 table.

  3. Once you have defined a DDM for a DB2 table, you can access the data stored in this table by using a Natural program.

Natural for 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 Using Natural Native DML Statements. In the Statements documentation, you can find notes on Natural usage with DB2 attached to the descriptions of the Natural DML statements concerned.

As there is no DB2 equivalent to Adabas internal sequence numbers (ISNs), any Natural features which use ISNs are not available when accessing DB2 tables with Natural.

For SQL databases, in addition to the Natural native DML statements, Natural provides Natural SQL statements; see Using Natural SQL Statements. They are listed and explained in the Statements documentation.