Reader Feedback and Insights: Dynamic Result Field in Query/400
October 11, 2002 Timothy Prickett Morgan
In the article “Dynamic Result Field in Query/400“, which appeared in Midrange Guru, OS/400 Edition, Bill wrote, “Every month we run a query that reports year-to-date sales. The year-to-date sales field, YTD$, is defined as result field that adds up monthly numeric buckets from a sales detail file. For example, the YTD$ for March will contain the expression Jan+Feb+Mar. However, before we can run this query each month, we have to add the next month to the expression. We would like to avoid having to modify the expression every month. Is there a way to make this query read the expression from a database file?”
Another approach that might work is to use the Open Query File (OPNQRYF) command, followed by a Copy From Query File (CPYFRMQRYF) command.
Or, Bill could actually create 12 queries: the first one would be just for January, the second January and February, and so forth. This way, each query could indicate in the title or footer text, what period it is for. Bill could use a CL program to choose which query to run.
Do you agree?
Sure, Bruce. Both of those solutions should work. I wouldn’t be too inclined to create 12 queries, because I’d hate to have to make 12 modifications if I had to change something.
Thanks for the suggestions, Bruce.
ADVANCED SYSTEMS CONCEPTS
SEQUEL meets all your iSeries and AS/400 data access needs in a single, integrated solution:
Take 6 minutes to view a SEQUEL ViewPoint ScreenCam movie to see how simple Windows-based AS/400 and iSeries data access can be! In just a few short minutes, you can find out ways to make your job easier and improve data access throughout your organization. Download the ViewPoint movie here .
For more information or a FREE trial of SEQUEL, call 847/605-1311 or visit Advanced Systems Concepts.