TechTalk: Selecting Records With OPNQRYF

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

From: Dennis Detwiler To: All

I'm doing an OPNQRYF to limit access to certain records. The CL program works; but when a subfile is displayed, it includes records that I was trying to eliminate. Is this something peculiar to subfiles? This file contains records organized by Officer. I'm comparing the user ID to a cross-reference file to get the initials and then doing an OPNQRYF for those initials compared to the field in the file I'm accessing.

From: Ted Holt To: Dennis Detwiler

If you're getting records you don't intend to get, first make sure that the input file has the SHARE(*YES) attribute (see 6). People usually do this by overriding the database file before calling the high-level language (HLL) program.

If you're getting records you don't intend to get, first make sure that the input file has the SHARE(*YES) attribute (see Figure 6). People usually do this by overriding the database file before calling the high-level language (HLL) program.

If file XYZ is not shared, HLLPGM will not read the OPNQRYF file, but will read the file directly.

If that's OK, the next thing I would check for is errors in logical operators-*AND, *OR, *NOT. Are you using any of them in the QRYSLT parameter?

I would also check for errors with concatenation operators. For example, using *BCAT when you really need *CAT can make OPNQRYF retrieve the wrong records.

Check these things out. If you still have trouble, send another message and include that part of your CL program.

From: Tim Johnston To: Dennis Detwiler

I know where you are coming from. In addition to Ted's comments, here's another trick I try. Once I run the OPNQRYF against the file, I will do a Copy From Query File (CPYFRMQRYF) command to a file in QTEMP. Then I will look at it with the Run Query (RUNQRY) command like this:

RUNQRY QRYFILE((QTEMP/file))

This gives me a picture of what data is being fed to the program. With me, nine times out of ten, it's the *ANDs and *ORs that give me a headache.


TechTalk: Selecting Records With OPNQRYF

Figure 6 Overriding a File Used by OPNQRYF to SHARE (*YES)

 OVRDBF FILE(XYZ) SHARE(*YES) OPNQRYF FILE((XYZ)) QRYSLT(whatever) etc. CALL PGM(HLLPGM) CLOF OPNID(XYZ) DLTOVR FILE(XYZ) 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: