skipping duplicate row values in a table...

sfaiz

New Member
Hi...I am using Progress 9.1e..
We have got a table where 2 rows have exactly same First name and Last Name values. What I am trying to achieve is trying to ignore rows in my program from this table which has duplicate values such as this. I am new to Progress and don't know what the equivalent syntax is in Progress for getting the distinct value, or skipping the duplicate values of a table.

in my program i have got the following query syntax:

Code:
for each sy-contact fields(sya-first-name sya-family-name sya-signatory)
                                        where sya-internal
                                          and sya-type = 'company'
                                          no-lock:

            if (sya-signatory = 'n/a') or (sya-signatory = '') then next.
so what can be done to skip the 2 rows which has the exact first name and family name values. any help would be much appreciated. thanks.

sayed
 
Do you want to ignore both rows or just one of them? It is not overly clear from the OP.

Assuming you want one of them, I would use a Temp-Table:

Code:
def temp-table tt-contacts
  field sya-first-name
  field sya-family-name 
  field sya-signatory
  index i-main sya-first-name sya-family-name.
for each sy-contact fields(sya-first-name sya-family-name sya-signatory)
                                        where sya-internal
                                          and sya-type = 'company'
                                          no-lock:

  if (sya-signatory = 'n/a') or (sya-signatory = '') then next.
  find tt-contacts where
        tt-contacts.sya-first-name = sy-contact.sya-first-name and
        tt-contacts.sya-family-name = sy-contact.sya-family-name no-error.
  if not avail tt-contacts then
  do:
     create tt-contacts.
     assign tt-contacts.sya-first-name = sy-contact.sya-first-name
              tt-contacts.sya-family-name = sy-contact.sya-family-name
              tt-contacts.sya-signatory = sy-contact.sya-signatory.
  end.
end.
for each tt-contacts:
    < whatever you wish to do with the data >
end.
 
You can do a couple of different things without a temp-table. One simple approach is to define a couple of variables for the two names and set them at the end of the loop. Then, at the beginning of the loop test to see if the new record is the same and, if so, use NEXT to skip the rest of the processing or put all the processing in an IF block.

You could also do it with BREAK BY and FIRST-OF.
 
Back
Top