According to the UniData documentation (UniData UniBasic Commands
Reference (BASR.pdf), Appendix B), @SYSTEM.RETURN.CODE is supposed to be
the number of items in the select list.  This is for all the various
SELECT commands, (SELECT, SSELECT, NSELECT, QSELECT), not just BSELECT.

Using the example below, @SYSTEM.RETURN.CODE should be 60, just like
SYSTEM(11).  It should not be 20, which is the number of records
scanned/queried.  If other selects worked that way, then @SYSTEM.RETURN
code for any SELECT would return the number or records in the file, or
the number of items in an active list before the command was executed.
For example, if there were 100 Customers, 20 of which were in Ohio, the
"SELECT CUSTOMER WITH STATE = "OH" would select 20 records with
@SYSTEM.RETURN.CODE = 100 and SYSTEM(11) = 20.


[re: OFF TOPIC ASIDE]
That is our typical structure also, but there are times where we do
multiple selects and that is where BSELECT bit us.  Something like this:

EXECUTE \BSELECT PO.HEADER WITH DATE EQ "6/27" DIRECT.INVOICES\
IF @SYSTEM.RETURN.CODE GT 0 THEN
  EXECUTE \BSELECT AP.TO.PO.XREF WITH VENDOR EQ "12345" PURCH.AGENT\

If there were PO.HEADER records that met the selection criterion but
DIRECT.INVOICES were null for all, there would be no active list after
the first BSELECT.  Unfortunately, @SYSTEM.RETURN.CODE will not be 0, so
the second BSELECT will execute but act against the whole file instead
of a limited list, which is not the intended action.

[/re: OFF TOPIC ASIDE]



> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> [EMAIL PROTECTED]
> Sent: Wednesday, June 27, 2007 9:52 AM
> To: u2-users@listserver.u2ug.org
> Subject: RE: [U2] RE: [UD] BSELECT @SYSTEM.RETURN.CODE anomaly
> 
> Dean Armbruster wrote on 26 Jun 2007 16:14:21 -0400
> 
> > ... This is about BSELECT ...
> >
> > @SYSTEM.RETURN.CODE is not supposed to be the number of
> > *records* selected.  It is supposed to be the number of 
> items in the 
> > select list.
> 
> I would suggest that, in this case, the documentation is 
> incorrect (or at least unclear), not the return code.
> 
> Why?  Because BSELECT allows you to select more than one 
> attribute.  From the help:
> 
> "Unlike the SELECT command, which retrieves only record IDs, 
> BSELECT builds a list of the attributes you name in the 
> UniQuery statement."
> 
> Typically, this command is used to get record ID's stored in 
> one file (e.g., BSELECT ORDER.HEADER LINE.KEY), but it can 
> also be used to get a SET of fields.  For example, 
> 
> BSELECT CUSTOMER WITH STATE = "OH" NAME PHONE FAX
> 
> In this case, I would get a list with (typically) three 
> entries for each of my Customers in Ohio:  Name, Phone and 
> Fax, in repeating order.  If I have 20 customers in Ohio 
> would expect @SYSTEM.RETURN.CODE to return 20 (the number of 
> items/records selected), and I would expect SYSTEM(11) would 
> have the total number of items in my list (i.e., 60).  
> However, if any of the fields were multi-valued, I would get 
> ALL of those values in my list, just as if I had used a 
> BY-EXP in a sort.
> 
> > Watch out!  @SYSTEM.RETURN.CODE for BSELECT is not what the 
> > documentation says it is.  Your list may not have the number of 
> > entries indicated.  Your list may even be empty even though 
> > @SYSTEM.RETURN.CODE is greater than zero.
> 
> Can you support this last statement?  In every test I ran, 
> @SYSTEM.RETURN.CODE was the number of records selected, and 
> @SYSTEM(11) was the total number of items.  Of course, I tend 
> to BSELECT FILE WITH ATTR ATTR...
> 
> --Tom Pellitieri
>   Century Equipment
> 
> [OFF TOPIC ASIDE]
> 
> For what it's worth, I was taught to check SYSTEM(11) for the 
> number of items returned by an EXECUTE statement, although 
> typically I don't check it at all.  My "usual" processing loop uses:
> 
> CTR = 0
> EXECUTE \SELECT ...\
> LOOP WHILE READNEXT ID DO
>   CTR += 1
>   ...
> REPEAT
> 
> So CTR has my processed count, and if there isn't anything to 
> process, the loop exits immediately.
> 
> [/OFF TOPIC ASIDE]
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to