DDM files and SQL

You can use iSeries™ distributed data management (DDM) support to help you do some distributed relational database tasks within a program that also uses SQL distributed relational database support.

It might be faster, for example, for you to use DDM and the Copy File (CPYF) command to get a large number of records rather than an SQL FETCH statement. Also, DDM can be used to get external file descriptions of the remote system data brought in during compilation for use with the distributed relational database application. To do this, you need to use DDM as described in Initial setup.

The following example shows how you can add a relational database directory entry and create a DDM file so that the same job can be used on the application server (AS) and application requester (AR).
Note: Either both connections must be protected or both connections must be unprotected for the conversation to be shared.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
Relational Database Directory:
 
ADDRDBDIRE    RDB(KC000) +
              RMTLOCNAME(KC000)
              TEXT('Kansas City regional database')
DDM File:
 
CRTDDMF  FILE(SPIFFY/UPDATE)
         RMTFILE(SPIFFY/INVENTORY)
         RMTLOCNAME(KC000)
         TEXT('DDM file to update local orders')

Here is a sample program that uses both the relational database directory entry and the DDM file in the same job on the remote server:

 
CRTSQLxxx PGM(PARTS1) COMMIT(*CHG)  RDB(KC000) RDBCNNMTH(*RUW)
 
    PROC :PARTS1;
    OPEN  SPIFFY/UPDATE;
       .
       .
       .
    CLOSE SPIFFY/UPDATE;
       .
       .
       .
    EXEC SQL
      SELECT * INTO :PARTAVAIL
               FROM INVENTORY
               WHERE ITEM = :PARTNO;
    EXEC SQL
      COMMIT;
       .
       .
       .
    END PARTS1;
Related concepts
Distributed data management
Related reference
Copy File (CPYF) command