Manipulate data in tables and files using the iSeries query management function

The i5/OS™ licensed program provides a DB2 Universal Database™ for iSeries™ query management function that allows you to manipulate data in tables and files. A query is created using an SQL query statement.

You can run the query through CL commands or through a query callable interface in your application program. Using the query management function, you can insert a row of data into a table for the inventory updates described in the Load data into a table using SQL as follows.

Create a source member INVLOAD in the source physical file INVLOAD and the SQL statement:

INSERT INTO SPIFFY/INVENT
   (PART, DESC, QTY, PRICE)
 VALUES
   (&PARTVALUE, &DESCVALUE, &QTYVALUE, &PRICEVALUE)

Use a CL command to create a query management query object:

CRTQMQRY QMQRY(INVLOAD) SRCFILE(INVLOAD) SRCMBR(INVLOAD)

The following CL command places the INSERT SQL statement results into the INVENT table in the SPIFFY collection. Use of variables in the query (&PARTVALUE, &DESCVALUE, and so on) allows you to enter the desired values as part of the STRQMQRY call, rather than requiring that you create the query management query again for each row.

STRQMQRY QMQRY(INVLOAD) RDB(KC000)
   SETVAR((PARTVALUE '1134567'') (DESCVALUE '''Lug Nut''')
    (QTYVALUE 25) (PRICEVALUE 1.15)) 

The query management function is dynamic, which means its access paths are built at run time instead of when a program is compiled. For this reason the DB2® UDB for iSeries query management function is not as efficient for loading data into a table as an SQL application. However, you need the IBM® DB2 Query Manager and SQL Development Kit for iSeries product to write an application; runtime support for SQL and query management is part of the i5/OS licensed program.

Related concepts
Query Management Programming PDF