Apr 3, 2014

ABL Do Loop

def var success as logical no-undo.
assign success = no.
do while success = no:
        assign success = yes.
end.

The simplest code that does the same thing as a SELECT DISTINCT statement is the following:
FOR EACH SomeTable NO-LOCK WHERE SomeConditions BREAK BY SomeField:
    IF FIRST-OF(SomeField) THEN
        /* Do What You Want With The Record Here */
END.

If you need to implement DISTINCT for multiple fields thae you will need to change the code to something like the following:
FOR EACH SomeTable NO-LOCK WHERE SomeConditions BREAK BY SomeField1 BY SomeField2:
    IF FIRST-OF(SomeField1) AND FIRST-OF(SomeField2) THEN
        /* Do What You Want With The Record Here */
END.

0 comments:

Post a Comment

Nam Le © 2014 - Designed by Templateism.com, Distributed By Templatelib