Can you update physical file through OPNQRYF?

285 pts.
Tags:
AS/400
OPNQRYF
Can we update physical file through OPNQRYF command in clle (AS400)?Is it possible? 

OPNQRYF FILE((lib/pf)) OPTION(*UPD) QRYSLT('CDE + *EQ 101 ') KEYFLD((CDE))                    


Software/Hardware used:
AS400 (RPG,CL)

Answer Wiki

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

You can create a view in runtime for a Physical file using OPNQRYF.

OPNQRYF FILE((lib/pf)) OPTION(*UPD) QRYSLT(‘CDE +
*EQ 101 ‘) KEYFLD((CDE))

The Above statement will create a view for PF in runtime.
Option ‘*UPD indicates to Open the file for update operations.
QRYSLT is used to filter the records, In this case PF will pick up the records only if CDE equals to ‘101’.
KEYFLD(CDE), CDE will act as a Keyfield in this case and Records will be ordered based on CDE.

Pradeep.

Discuss This Question: 8  Replies

 
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
  • philpl1jb
    1. The CLLe cannot update the file 2. The opnqryf has opened the file for update 3. If the CLLE includes an OVRDBF Share(*YES) 4. subsequent calls to RPG or COBOL will use the Record set from the OPNQRYF and can update it. 5. CLEL program should end the relationship with a CLOF and DLTOVR
    51,365 pointsBadges:
    report
  • bvining
    Vendor response. CL applications can update files accessed through OPNQRYF (or other means for that matter) using Control Langauge for Files (CLF). This can be done using the no-charge runtime support of CLF or, for improved programmer productivity, the fee-based pre-compiler. Further information can be found at this site. End vendor response.
    6,620 pointsBadges:
    report
  • philpl1jb
    Sorry Bruce, didn't intend to leave you out. Phil
    51,365 pointsBadges:
    report
  • pdsathishkumar
    Mr. Pradeep and Mr. Phil can you explain, below statement, Option '*UPD indicates to Open the file for update operations. my point is, we can't update PF using OPNQRYF. but 'The opnqryf has opened the file for update' - this s ur point, how it is possible....
    3,790 pointsBadges:
    report
  • TomLiotta
    we can’t update PF using OPNQRYF. but ‘The opnqryf has opened the file for update’ - this s ur point, how it is possible…. It's possible because that is what IBM created the command to do. It opens a query file. It doesn't do updating. It just provides a file for your programs to update. OPNQRYF creates a temporary open data path (an ODP) that can be used by programs in the job. When you use the OPTION(*UPD) parameter, the ODP is created with update capability. The file that is named on the OPNQRYF can be shared in the job, so other programs can issue update statements against the file. Every program that opens the file can share the ODP. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    If you think of the F-spec in RPG The Fmyfile UF will allow updates of a file but that statement doesn't actually update the file, it open the file in update mode. The OpnQryF does the same thing, open the file in update mode, the OVRDBF Share(*yes) allows the open with update to be passed with the call to RPG or COBOL (or Bruce's CL commands) where rows in the underlining physical file can be changed. If you have an SQL background, think of this as aboout the same as a Select with update command. Phil
    51,365 pointsBadges:
    report
  • philpl1jb
    "Can we update physical file through OPNQRYF command " The meaning of the word THROUGH maybe the issue. Through this one command can we change the data, NO! Though the path opened by this command can subsequent commands especially subsequent programs in RPG or COBOL;change the data, yes, As computer programmers we have an uneasy relationship with the lan guage that specifications are written in. Words and sentences can have more than one meaning. Phil
    51,365 pointsBadges:
    report
  • deepu9321
    As Philip Mentioned, OPNQRYF will just create a view for the actual file. here, *UPD means, The file is opened for update operations. The Updates to File can be done in the following programs(Like, RPGLE). I guess, you will be able to get better idea if you can observe all the Possible vaues for OPTION. *ALL Open the file for all operations (*INP, *OUT, *UPD,*DLT). *INP Open the file for input. *INP is the only value allowed if join processing or group processing is requested, if UNIQUEKEY processing is specified, if all the fields in the open query file record format specified for the Format specifications (FORMAT) parameter are for input-only use, or if a temporary file is required to run the query. *OUT Open the file for output. In some high-level languages, output to certain files (such as files defined as 'direct access' in the high-level language program) is done by using a combination of input and update operations. *UPD and *INP are specified, or *ALL is specified, in order to use an open query file with Such a program. *UPD Open the file for update operations. If an input operation comes before an update, you must specify *INP when *UPD is specified. *DLT Open the file for delete operations. If a delete operation is preceded by an input operation, you must specify *INP when *DLT is specified. Pradeep.
    4,290 pointsBadges:
    report

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