Normal Topic Selective Duplicate Delete in Sesame (Read 417 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Selective Duplicate Delete in Sesame
Mar 7th, 2004 at 11:53pm
Print Post Print Post  
Sesame gives option to delete duplicate records but in order to have them deleted, all the elements have to be the same.  Not so in Q&A. In Q&A there is a choice if you want to remove the records with certain duplicate fields. Such capability has been useful to me in order to keep certain databases slim and managable.

Well, I came to find out it is not difficult to emulate that in Sesame with following two line code. If you are a frequent users of this, you might want to automize this using command button and storing the Retrieve spec, mass update spec, sort spec and using @selectTreeItem( ) and @Load(various)spec( ).  

RecNumber is what I am checking for duplicate entry and Name is one of the text fields in the form.

var n as Int

           n = @ResultSetCurrentPosition ( )       

           If @FormFieldValue ("YourForm", "RecNumber", n) = @FormFieldValue ("YourForm", "RecNumber", (n + 1)) then
                 {
                       Name = Name + " To be Deleted"
                 }

/*
This code is used to remove duplicate records based on selected duplicate elements similar to option available in removal of duplicate records in Q&A. This code will first flag the records to be deleted in one of the text fields.

Get the record set of all the records. You may add other duplicate elements in the condition part using "and" in the if statement to choose multiple duplicate elements.  

Sort all Duplicate elements in Ascending order (for whatever you would put "D" in Q&A Removal spec
last sort the Counter field in ascending order.

The above sort will assure that the latest record will be preserved.

Mass Update using above code
Delete or export and delete all the flagged records.

If you ever have to undo the process just remove the flag using
Name = @Replace (Name, "To be Deleted", "")
*/
  
Back to top
 
IP Logged