Here is a strategy I have used since V6 to enforce a semi-informal primary key
for records in an important file. Another parameter was added when our business
changed a few years ago. I think you could make it work for your task:
C_BOOLEAN($0;$DupExists)
C_TEXT($2;$3;$Value1;$Value2)
C_LONGINT($1;$CurrentKey;$4;$Value3)
$CurrentKey:=$1
$Value1:=$2
$Value2:=$3
If (Count parameters>3)
$Value3:=$4
Else
Value3:=0
End if
$DupExists:=False
CREATE SET([Contracts];"Duplicates")
SET QUERY DESTINATION(Into set;"Duplicates")
QUERY([Table];[Table]Value1=$Value1;*)
QUERY([Table]; & ;[Table]Value2=$Value2;*)
if($Value3#0)
QUERY([Table]; & ;[Table]CAID=$Value3;*)
End if
QUERY([Table]; & ;[Table]Key#$CurrentKey) //In case record we are checking has
already been saved
If (Records in set("Duplicates")>0)
$DupExists:=True
End if
SET QUERY DESTINATION(Into current selection)
CLEAR SET("Duplicates")
$0:=$DupExists
JJ
> On Oct 31, 2017, at 3:12 PM, [email protected] wrote:
>
> Message: 4
> Date: Tue, 31 Oct 2017 14:40:50 -0600
> From: David Witton <[email protected] <mailto:[email protected]>>
> To: 4D iNug Technical <[email protected] <mailto:[email protected]>>
> Subject: identify duplicates
> Message-ID:
> <cae-8fqy9hmzfuptgxd0--cohhuu+diumg9ne6mlignduu_x...@mail.gmail.com
> <mailto:cae-8fqy9hmzfuptgxd0--cohhuu+diumg9ne6mlignduu_x...@mail.gmail.com>>
> Content-Type: text/plain; charset="UTF-8"
>
> I'm looking for a strategy to identify duplicate records in a table - that
> is, records for which 3 fields are identical across two or more records -
> or in another case, where a single field is not unique.
>
> Does anyone have a suggestion on how to proceed?
>
> --
> David Witton
>
>
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************