TechTalk: OPNQRYF with Sets of Values

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

From: Eric Hill To: All

I have a need to use the concatenate (*CAT) operand in Open Query File. I have a variable called &OCODE that is character, 360 bytes in size, and contains a group of states that I want selected with a blank between each state (AL CA AR TX). I want to select all the records in my Cus-tomer Master file that are in that group of states. I have tried this using the QUSRTOOL command BLDQRYSLT, but it says that my select statement has more than 15 characters in it. I have tried it using the "E and *CAT example in the February issue of MC, and nothing seems to work.

From: Ted Holt To: Eric Hill

You'll have to go through the routine of extracting each state and adding it to the list of values used by the %VALUES function. 5 shows an example of this technique.

You'll have to go through the routine of extracting each state and adding it to the list of values used by the %VALUES function. Figure 5 shows an example of this technique.

This routine is slightly different from your requirements in that you wouldn't have to leave blanks between states, or you could leave one or more blanks between them.

Editor's Note: To work properly, the program in 5 must be executed via a command or called from another proram. It will not work properly if called directly from the command line unless you make sure to include 360 characters in the first parameter. The reason for this is that when character parameters longer than 32 bytes are passed via the CALL command, there is no guarantee that all characters beyond the last non-blank will contain blanks. The only way to ensure they're blanks is by including all 360 characters of the parameter when calling the program.

Editor's Note: To work properly, the program in Figure 5 must be executed via a command or called from another proram. It will not work properly if called directly from the command line unless you make sure to include 360 characters in the first parameter. The reason for this is that when character parameters longer than 32 bytes are passed via the CALL command, there is no guarantee that all characters beyond the last non-blank will contain blanks. The only way to ensure they're blanks is by including all 360 characters of the parameter when calling the program.


TechTalk: OPNQRYF with Sets of Values

Figure 5 OPNQRYF With Sets of Values

 PGM PARM(&OCODE) DCL VAR(&OCODE) TYPE(*CHAR) LEN(360) DCL VAR(&QRYSLT) TYPE(*CHAR) LEN(512) VALUE('*ALL') DCL VAR(&N) TYPE(*DEC) LEN(3 0) IF COND(&OCODE *NE ' ') THEN(DO) CHGVAR VAR(&QRYSLT) VALUE('STATE = %VALUES(') CHGVAR VAR(&N) VALUE(1) LOOP: + IF COND(%SST(&OCODE &N 1) *NE ' ') THEN(DO) CHGVAR VAR(&QRYSLT) VALUE(&QRYSLT *BCAT '"' *CAT %SST(&OCODE + &N 2) *CAT '"') CHGVAR VAR(&N) VALUE(&N + 1) ENDDO CHGVAR VAR(&N) VALUE(&N + 1) IF COND(&N *LE 358) THEN(GOTO CMDLBL(LOOP)) CHGVAR VAR(&QRYSLT) VALUE(&QRYSLT *TCAT ')') ENDDO OVRDBF FILE(XXXXX) SHARE(*YES) OPNQRYF FILE((XXXXX)) QRYSLT(&QRYSLT) etc. /* If &OCODE is 'AR AZ CA AL', you'll get + QRYSLT('STATE = %VALUES( "AR" "AZ" "CA" "AL")') */ 
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: