OVRDBF can be used to redirect the file selection to a file of another name or in a specific library.
OPNQRYF provides a method to select records, join files, etc. It is a lot like SQL select.
We would usually see the two together - the override requires the share(*yes) so called programs get access to the query file. Here is a CL
pgm
OVRDBF file(xxxx) share(*yes)
OPNQRYF file(xxxx) QRYSLT( 'STFLD = "MO"'))
Call rpg1
CLOF OPNID(xxxx)
DLTOVR(*ALL)
endpgm
This query would limit select records to those with MO in the STFLD.
It would appear to program rpg1 that the file xxxx only contained records for 'MO'
This can provide flexibility to a rather simple RPG program.
The QrySlt can be a *char variable which you can build based on your current need.
There is much more to these commands.
Phil
Regarding OPNQRYF: It uses the original, or classic query engine (CQE) which IBM is no longer enhancing for performance and additional functionality, so it is better to use embedded SQL.
SQL statements will generally use the newer engine, SQE, except in certain circumstances. The goal is to have the system use the SQE, which should perform better. One of the ways to facilitate this is to query just the physical file or table in an SQL statement, and let the system figure out which index it finds best to use. Using a logical file will result in the system using the CQE instead, which is less desirable from a performance perspective.
Also, see these for some detailed info:
<a href="http://www.itjungle.com/fhg/fhg040908-story01.html">http://www.itjungle.com/fhg/fhg040908-story01.html</a>
<a href="http://itknowledgeexchange.techtarget.com/itanswers/progress400-with-db2400?asrc=EM_UGT_3964085&uid=5731771">http://itknowledgeexchange.techtarget.com/itanswers/progress400-with-db2400?asrc=EM_UGT_3964085&uid=5731771</a>
Charles
Last Wiki Answer Submitted: July 2, 2008 2:45 pm by Cwc4,275 pts.
All Answer Wiki Contributors: Cwc4,275 pts. ,
philpl1jb44,160 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.