The usage of FIRST, FIRST-OF LAST-OF and LAST functions

JamesBowen

19+ years progress programming and still learning.
Hi

I am looping on a dynamic query and I want to user the
FIRST, FIRST-OF, LAST-OF and LAST functions.

In the manual is states:
Returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK block is the first iteration of that block.

How can I use theses function on a REPEAT: block?

I am just having a RTFM moment and not seeing the light.

Thanks.
 
Ok.

Looking at KBase ID: 20296 and ID: 20295.
Simple answer is you can't.

But there are work around.

You would think that PSC would have added new attributes and methods to the Query object handle. IS-FRIST & IS-LAST attributes and FIRST-OFF() & LAST-OF() methods.

Or am i asking for the the impossible and that there is a reason why this could not be done?
 
I did'nt understand it either. But there seems to be some sun on the horizon: in 10.1C this functionality should be available for dynamic queries as well.
From exchange 2007 presentation DEV-16 ABL Database objects updated:
DEFINE QUERY q FOR Customer,Order, Order-line, Item SCROLLING.

OPEN QUERY q FOR EACH Customer WHERE Customer.Cust-num < 10,
EACH Order OF Customer,
EACH Order-line OF Order,
EACH Item OF Order-line
BREAK BYCustomer.Sales-rep BY Order.Order-num.

REPEAT:
GET NEXT q.
IF QUERY q:LAST-OF(2) THEN …. Done with this order
IF QUERY q:LAST-OF(1) THEN … Done with this sales-rep
etc etc.
END.


Works for both dynamic and static QUERY OPEN

I didn't see anything about is-first or is-last. But I can imagine that will be implemented as well :awink:

Casper
 
Back
Top