Thanks Bill, The Dev was pulling his hair out for a while working out why some code was apparently processing 8 records, but only actually did it on 4. The joys of working with legacy code (or any code, I guess.) :)
I think the code we are running was ported from Pick to UD 5.x originally, so potentially these programs code have been subtly misbehaving for over 20 years now, or just since we upgraded to 7.x -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Bill Haskett Sent: Tuesday, 13 October 2009 9:52 AM To: U2 Users List Subject: Re: [U2] EXECUTE 'CLEARSELECT' Dan: I'm running v7.2 here in my development environment and v7.1 elsewhere in several production environments. This program runs the same on both environments: 2 Dev (0)-> BPTEST EXECUTE \SELECT TEMP\ CAPTURING OUTPUT ; NoOfItems = SYSTEM(11) ; CRT NoOfItems : ' selected...' ; CLEARSELECT ; CRT SYSTEM(11) : ' items after CLEARSELECT...' ; END Compiling Unibasic: SAVEDLISTS\BpTest_553739081 in mode 'p'. compilation finished 6 selected... 0 items after CLEARSELECT... This isn't the same as you wrote (you inserted READNEXTs between these commands) but it did respond as I expected. We should note I use exclusively PICK mode (a combination of UDT.OPTIONS settings and a few other settings). I ran your program and got the following: 2 Dev (0)-> RUN BP BILL 10 records selected to list 0. Records after SELECT 10 Records after EXECUTE CLEARSELECT: 9 10 records selected to list 0. Records after SELECT 9 Records after CLEARSELECT: 0 10 records selected to list 0. Records after SELECT 10 2 Dev (0)>> LIST TEMP LIST TEMP 15:38:44 Oct 12 2009 1 TEMP...... ARTCHOLD ARLEDGER.FIX ARTL.UPD ATGUIERROR APREVIEW APPEND.ACCT ATGUIGETPROPS ATGUICREATELIST A9 ADD.MULTIVALUES 10 records listed 2 Dev (0)-> But I noticed you did an "EXECUTE \CLEARSELECT\" in your code instead of "CLEARSELECT". When I changed that particular line and reran the program I got the following: 2 Dev (0)-> RUN BP BILL 10 records selected to list 0. Records after SELECT 10 Records after EXECUTE CLEARSELECT: 0 10 records selected to list 0. Records after SELECT 10 Records after CLEARSELECT: 0 10 records selected to list 0. Records after SELECT 10 2 Dev (0)>> So, I'd suggest using a BASIC "CLEARSELECT" as an execute should only clear the select within the new process created with the EXECUTE statement. I've converted a number of sites from D3 to UniData and noticed that, in rare instances, SYSTEM(11) doesn't work as advertised but in that case I was able to use @SYSTEM.RETURN.CODE after the select. Also, when using DesignBais we've noticed an unusual UniData list problem where a select list is carried beyond its scope back into another program. The code we had to use to fix this UniData bug was: *************** SELECTION: *************** * ** Fix a UniData bug that holds unused select lists CLEARSELECT * ** Parse some other information regarding the query xHigh = DCOUNT(DBSTORE(QUERYSLOT0), @AM) FOR X = 1 TO xHigh TclCmd = DBSTORE(QUERYSLOT0)<X> IF X < xHigh THEN EXECUTE TclCmd CAPTURING Output IF NOT(SYSTEM(11)) THEN EXIT END END ELSE EXECUTE TclCmd RTNLIST DBRETURN.SELECT(1) CAPTURING DBSTORE(QUERYRESULT) RETURNING MSG1 * ** Need to clear select to fix the UniData bug CLEARSELECT END NEXT X RETURN HTH, Bill Dan McGrath said the following on 10/12/2009 2:56 PM: > Thanks for the replies, > > @David Hona > > Thanks for that. There shouldn't be an issue with the execution layer of > EXECUTE in regards to select lists as the following processes correctly: > > Giving a FILE, X with 3 records: AA, AB and BB > > EXECUTE 'SELECT X with @ID = "A]"' > EXECUTE 'SELECT X with @ID = "[B"' > > Correctly returns 1 record, AB. > > I tested all the EXECUTE/PERFORM variants with the below code and the > only one that makes a difference is UDTEXECUTE "CLEARSELECT", which > works as advertised. > > The difference between UDTEXECUTE and EXECUTE is that UDTEXECUTE always > processes the commands in ECLTYPE U. > > >From the Manual for UDTEXECUTE: > > "When you compile a program in BASICTYPE P, EXECUTE or PERFORM passes > the string to execute to a nonstandard UniData parser. This parser looks > for a specific sentence structure common to BASICTYPE P systems. > Standard UniQuery sentences might not be handled correctly in this > circumstance. Therefore, when you want to execute a standard UniQuery > statement from within a UniBasic program that has been compiled in > BASICTYPE P, use the UDTEXECUTE command instead of EXECUTE or PERFORM." > > CLEARSELECT, however, should be valid for Pick and should function > correctly. > > This leads me to believe, at least in UD 7.1, that the Pick Parser used > in EXECUTE when in BASICTYPE P is broken in regards to CLEARSELECT (As > evidenced by the SELECT response and SYSTEM(11) disagreement.) > > Our problem now is that we have many existing programs that use EXECUTE > "CLEARSELECT" that we now need to verify are functioning correctly and > fix as required. > > Mainly, I was interested if anyone else who has to operate their UD > system in ECLTYPE P, BASICTYPE P that is > - Aware of this issue, > - Can verify it outside of 7.1 (Eg, 7.2) > > @David Laansma > > Yes, we are aware of that. The below code is simply a trivial example > program to demonstration the issue. The issue comes into play when, for > example, you do a SELECT on a FILE and need to bail out part way through > processing the select list, then attempt to perform a new SELECT the > same file. > > In this case, if your program is compiled in BASICTYPE P and used > EXECUTE "CLEARSELECT" to clear the select list from the first SELECT, it > will not actually clear the select list and result in the second SELECT > being incorrect. > > Regards, > Dan > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Dave Laansma > Sent: Monday, 12 October 2009 11:03 PM > To: U2 Users List > Subject: Re: [U2] EXECUTE 'CLEARSELECT' > > If you goal is to simply count the number of records that match a > criteria, consider the COUNT statement. > > David Laansma > IT Manager > Hubbard Supply Co. > Direct: 810-342-7143 > Office: 810-234-8681 > Fax: 810-234-6142 > www.hubbardsupply.com > "Delivering Products, Services and Innovative Solutions" > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Hona, David > Sent: Monday, October 12, 2009 12:55 AM > To: U2 Users List > Subject: Re: [U2] EXECUTE 'CLEARSELECT' > > This usually indicates that your EXECUTE is executing at a different > execution layer. Prime INFORMATION did this by default and had to use > PERFORM to use the same runtime execution layer or overide with a > $option statement. > > ________________________________________ > From: [email protected] > [[email protected]] On Behalf Of Dan McGrath > [[email protected]] > Sent: Monday, 12 October 2009 1:56 PM > To: [email protected] > Subject: [U2] EXECUTE 'CLEARSELECT' > > Hi all, > > > > One of the programmers here has noticed this quirky behaviour in Unidata > 7.1. > > > > First, we created a file called TEST and gave it 3 records, AA, AB and > AC. Then we executed the following program: > > > > PROGRAM TEST > > > > CLEARSELECT > > EXECUTE 'SELECT TEST WITH @ID = "A]"' > > CRT "Records after SELECT ":SYSTEM(11) > > > > READNEXT KEY ELSE NULL > > > > EXECUTE "CLEARSELECT" > > CRT "Records after EXECUTE CLEARSELECT: ":SYSTEM(11) > > > > EXECUTE 'SELECT TEST WITH @ID = "A]"' > > CRT "Records after SELECT ":SYSTEM(11) > > > > READNEXT KEY ELSE NULL > > > > CLEARSELECT > > CRT "Records after CLEARSELECT: ":SYSTEM(11) > > > > EXECUTE 'SELECT TEST WITH @ID = "A]"' > > CRT "Records after SELECT ":SYSTEM(11) > > > > STOP > > > > and received the following results: > > > > 3 records selected to list 0. > > > > Records after SELECT 3 > > Records after EXECUTE CLEARSELECT: 2 > > > > 3 records selected to list 0. > > > > Records after SELECT 2 > > Records after CLEARSELECT: 0 > > > > 3 records selected to list 0. > > > > Records after SELECT 3 > > > > We would expect SYSTEM(11) to return 0 after the EXECUTE "CLEARSELECT" > but it returns how many items were in the list prior to the CLEARSELECT. > Also odd is that the select itself returns that it selected 3 records, > but then SYSTEM(11) reports 2 and READNEXT will only extract 2 from the > list. The work around is to use Unibasic CLEARSELECT which functions > correctly as demonstrated above. When testing this using BASICTYPE "u" > and "WHEN @ID LIKE" the issue did not present itself. I have tested both > UNIX and Windows. > > > > Does this happen in 7.2? > > > > Regards, > > Dan > > > ######################################################################## > ################### > The information transmitted in this message and attachments (if any) is > intended only > for the person or entity to which it is addressed. The message may > contain confidential > and/or privileged material. Any review, retransmission, dissemination > or other use of > or taking of any action in reliance upon this information by persons or > entities other > than the intended recipient is prohibited. If you received this in > error, please > contact the sender and delete the material from any computer. > > The intended recipient of this e-mail may only use, reproduce, disclose > or distribute > the information contained in this e-mail and any attached files with the > permission of IMB. > ######################################################################## > ################### > _______________________________________________ > U2-Users mailing list > [email protected] > http://listserver.u2ug.org/mailman/listinfo/u2-users > > ************** IMPORTANT MESSAGE ***************************** > This e-mail message is intended only for the addressee(s) and contains > information which may be > confidential. > If you are not the intended recipient please advise the sender by return > email, do not use or > disclose the contents, and delete the message and any attachments from > your system. Unless > specifically indicated, this email does not constitute formal advice or > commitment by the sender > or the Commonwealth Bank of Australia (ABN 48 123 123 124) or its > subsidiaries. > We can be contacted through our web site: commbank.com.au. > If you no longer wish to receive commercial electronic messages from us, > please reply to this > e-mail by typing Unsubscribe in the subject line. > ************************************************************** > > > > _______________________________________________ > U2-Users mailing list > [email protected] > http://listserver.u2ug.org/mailman/listinfo/u2-users > _______________________________________________ > U2-Users mailing list > [email protected] > http://listserver.u2ug.org/mailman/listinfo/u2-users > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > ######################################################################## ################### > The information transmitted in this message and attachments (if any) is intended only > for the person or entity to which it is addressed. The message may contain confidential > and/or privileged material. Any review, retransmission, dissemination or other use of > or taking of any action in reliance upon this information by persons or entities other > than the intended recipient is prohibited. If you received this in error, please > contact the sender and delete the material from any computer. > > The intended recipient of this e-mail may only use, reproduce, disclose or distribute > the information contained in this e-mail and any attached files with the permission of IMB. > ######################################################################## ################### > _______________________________________________ > U2-Users mailing list > [email protected] > http://listserver.u2ug.org/mailman/listinfo/u2-users > _______________________________________________ U2-Users mailing list [email protected] http://listserver.u2ug.org/mailman/listinfo/u2-users ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ ########################################################################################### The information transmitted in this message and attachments (if any) is intended only for the person or entity to which it is addressed. The message may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. The intended recipient of this e-mail may only use, reproduce, disclose or distribute the information contained in this e-mail and any attached files with the permission of IMB. ########################################################################################### _______________________________________________ U2-Users mailing list [email protected] http://listserver.u2ug.org/mailman/listinfo/u2-users
