Newsletters   Subscriptions  Forums  Store  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 4, Number 19 -- June 2, 2004

Reader Feedback and Insights



Kudos for the Guru


I love the site. It's nice to have access to people in the industry that know what they are doing and are willing to share their knowledge. If you guys could just update the Four Hundred Guru page every day, life would just about be perfect!!!

--Bill



"Creating Dynamic Queries," by Bruce Guetzkow


Great article on parameters in STRQMQRY. However, the DCL statements might not be clear in the article.

The DCL statement for an 8 position alpha field would be as follows:

DCL   VAR(&ALPHA)   TYPE(*CHAR)   LEN(10)   VALUE('''abcdefgh''')

The DCL statement for an 8 position numeric field would be:

DCL   VAR(&NUMERIC)   TYPE(*CHAR)   LEN(8)   VALUE('12345678')

The alpha CHGVAR statement would be:

CHGVAR   VAR(%SST(&ALPHA 2 8))   VALUE(ALPHA_PARM)   

The numeric CHGVAR statement would be:

CHGVAR   VAR(&NUMERIC)   VALUE(NUMERIC_PARM)

The number of single quotation marks (') at the beginning and at the end of the alpha field must be 3, and the "numeric" field must be 1.

Thanks.

--Richard


Bruce Guetzkow responds: I typically use the following when I need to add quotes inside a variable:

DCL  VAR("E)    TYPE(*CHAR)  LEN(1)  VALUE('''')
DCL  VAR(&ALPHA10)  TYPE(*CHAR)  LEN(10)
DCL  VAR(&ALPHA12)  TYPE(*CHAR)  LEN(12)

CHGVAR  VAR(&ALPHA12)  VALUE("E *CAT &ALHPA10 *CAT "E)

This eliminates trying to figure out how many quotation marks I need in every concatenation. I only have to define the quotation mark one time, then use it wherever I need it. It makes the code much easier to read.

I've been using QMQRY for about 10 years now, and the biggest problem I've had is figuring out when I needed quotes and how many levels of quotes might be needed. (What if I'm looking for the quotation character as part of the text in my file?) It's at this point that I start looking for a consultant!

Thanks for the comment.

--Bruce Guetzkow
bguetzkow@itjungle.com


Very interesting article. I enclose the following post from Birgitta Hauser that I picked off of a newsgroup last year that allows prompting good old Query/400 queries without having to create the QMQRY. It was a real eye opener for me! Keep up the good work. Four Hundred Guru is one of the few newsletters I read.

--Pete Hurd

Ideas on full variables in Queries/CL: Do you want to pass variables for selection to a Query/400 and then run it? If so, change your selections in your Query using variables.

   :VarName
   Before:
   AND/OR  Feld              Test   Wert (Feld, Nummer, 'Zeichen'
oder...)
           FIRNR             EQ     100
    AND    ADTPA             EQ     'E'

   After:
   AND/OR  Feld              Test   Wert (Feld, Nummer, 'Zeichen'
oder...)
           FIRNR             EQ     :PFINR
    AND    ADTPA             EQ     :PTPA

Write a CL program to fill your variables, and run your query using STRQMQRY, instead of RUNQRY.

 PGM        PARM(&P$FINR &P$TPA)             

DCL        VAR(&P$FINR)  TYPE(*DEC)  LEN(3) 
DCL        VAR(&QryFINR) TYPE(*CHAR) LEN(3) 

DCL        VAR(&P$TPA)   TYPE(*CHAR) LEN(2) 
DCL        VAR(&QryTPA)  TYPE(*CHAR) LEN(4) 

ChgVar     Var(&QryFiNr) Value(&P$FINR)     
ChgVar     Var(&QryTpa)                     
                  Value('''' *cat &P$TPA *Cat '''')

StrQmQry   QmQry(MYQUERY)                  +
           Output(*PRINT)                  +
           QmForm(*QMQRY)                  +
           AlwQryDfn(*YES)                 +
            SetVar((PFINR &QryFiNr) (PTPA &QryTpa))

          ENDPGM
Sponsored By
ADVANCED SYSTEMS CONCEPTS

SEQUEL
beats the pants off
Query/400 !

Read the
Top Ten Reasons
why you should switch!

(Click Here)

FREE Trial - Call 847-605-1311
or use our online
Trial Request Form


Editors: Howard Arner, Joe Hertvik, Ted Holt,
Shannon O'Donnell, Kevin Vandever
Managing Editor: Shannon Pastore
Contributing Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
Guild Companies
WorksRight Sofware
Guild Companies
GST


BACK ISSUES

TABLE OF
CONTENTS
Pooling Your DataSources

Don't Let Overrides Deceive You

Query/400 and Multiple Detail Lines

Admin Alert: Checking Your iSeries Batteries

OS/400 Alert: Windows XP Service Pack 2 Beta


The Four Hundred
OS/400 Community Reacts to eServer i5

Java, .NET on iSeries Programmers Minds, RPG in Their Blood

Worldwide Server Market Perked Up in Q1

Four Hundred Stuff
Access OS/400 Servers from Wireless BlackBerry Devices

IBM Introduces Integration Software to the Midmarket

eStorage Offers 70 GB iSeries Disk Drive for $995

Four Hundred Monitor


Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, 50 Park Terrace East, Suite 8F, New York, NY 10034
Privacy Statement