View Full Version : OPNQRYF and numeric field.
Guest.Visitor
01-01-1995, 02:00 AM
I am trying to use OPNQRYF to select a range of date. This is the command i'm doing. OPNYQRYF FILE(MYFILE) QRYSLT('INVDATE *GE "' *CAT &FRDATE *CAT '" *AND INVDATE *LE "' *CAT &TODATE *CAT '"'). My variables are all numeric. At the compile, i'm receiving an error CPD0711(Operand in expression not same) & CPD0712(Operand in expression not have valid type). If i change my CL variable for Characters, it's compiling but i receive an error why i run the program (operand for *NL function not valid). I think it's a syntax error, but i have no reference for that. N.B. (from that, i'm ordering the Open Query File Magic book but i somebody can help me, before i'm receiving my book.) Thanks Gilbert.
Guest.Visitor
03-25-1999, 11:19 AM
Gilbert, I'll presume that your numeric dates are 8 digits long. I find it is helpful to lose the complicated QRYSLT statement. In this example, use the variable &QRYSLT in your OPNQRYF statement. <pre> DCL VAR(&FRDATE ) TYPE(*DEC ) LEN(8 0) DCL VAR(&TODATE ) TYPE(*DEC ) LEN(8 0) DCL VAR(&FRDATEC) TYPE(*CHAR) LEN(8) DCL VAR(&TODATEC) TYPE(*CHAR) LEN(8) DCL VAR(&QRYSLT ) TYPE(*CHAR) LEN(500) /* .... ....1.... ....2.... ....3.... ....4.... ....5 */ CHGVAR VAR(&QRYSLT) + VALUE('INVDATE *GE 00000000 *AND INVDATE *LE 00000000') CHGVAR VAR(&FRDATEC) VALUE(&FRDATE) CHGVAR VAR(&TODATEC) VALUE(&TODATE) CHGVAR VAR(%SST(&QRYSLT 13 8)) VALUE(&FRDATEC) CHGVAR VAR(%SST(&QRYSLT 39 8)) VALUE(&TODATEC) OPNQRYF FILE(MYFILE) QRYSLT(&QRYSLT) . . . </pre> Chris
Guest.Visitor
03-26-1999, 03:59 AM
Try the following it should work, it's all down to those damn quotes! Your mixing up character fields in the Query select parameter. OPNYQRYF FILE(MYFILE) QRYSLT('INVDATE *GE ' *CAT &FRDATE *CAT ' *AND INVDATE *LE ' *CAT &TODATE) If you have any more problems look in the "OS/400 DB2 for OS/400 Database Programming" manual Section 2.2.3.4. Dan
Guest.Visitor
03-27-1999, 01:50 AM
I have never understood why CHris's technique is not in any IBM manual. Also, I wish some eager beaver programmer would write a pgm to convert the SQL "SELECT" statement to OPNQRYF command.. The "WHERE" parm would become the qryslt parm in OPNQRYF. I would volunteer as a beta tester... <pre> <H4>Bob Hamilton TEXAS BUSINESS SYSTEMS 736 Pinehurst Richardson, Texas 75080 <h4> </pre></h4></h4>
Guest.Visitor
03-29-1999, 09:45 AM
On Saturday, March 27, 1999, 02:50 AM, Bob Hamilton wrote: I have never understood why Chris' technique is not in any IBM manual. Actually this is a technique I learned in "Open Query File Magic!", the same book that Gilbert ordered. I think he will like the book. Chris
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.