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