OPNQRY and OVRDBF

75 pts.
Tags:
OPNQRY
OVRDBF
Hi, Can you please tell me more about OPNQRY and OVRDBF and why we are going to use them? Thanks &Regars, Raum

Answer Wiki

Thanks. We'll let you know when a new response is added.

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:

Charles

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following