Is it possible to maintain a logical file(LF) with summary information of the data of a physical file (PF) using only DDS? I.e. If the Sales PF contains 10,000 records with invoice number, customer number, and invoice amount (one customer can have many invoices), then I want a LF with total of Invoice Amount for each customer (live summary values). If there is no solution through DDS, is there any other method?
There are no DDS keywords that provide this functionality. One option would be Database triggers. A set of Insert/Update/Delete triggers could be used to do this. Triggers created over the Sales PF would take the changes and then update the appropriate customer summary level in a second PF that holds the summary sales data. A second option would be creating an SQL view (CREATE VIEW sumsales AS (SELECT customer, Sum(Inv Amount) FROM sales GROUP BY customer). This SQL View can be opened as a non-key logical file -- the SQL view would have to recalculate the sales summary for each customer each time the SQL View was opened as a logical file.
MORE INFORMATION ON THIS TOPIC
Search400.com's targeted search engine: Get relevant information on DB2/400.
The Best Web Links: tips, tutorials and more.
Check out this Search400.com Featured Topic: Database issues resolved
Dig Deeper on DB2 UDB (universal databases)
Related Q&A from Kent Milligan
Create a host variable of the where in statement on the fly with dynamic SQL. Continue Reading
To solve the SQL error -321 on IBM i6.1, use the new values statement to overcome the error. If you are using an older release, declare a cursor ... Continue Reading
When working with DB2 files with columns that have both short and long names, there is no option choose which column names are returned via ODBC ... Continue Reading