Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!ames!uhccux!bmartin From: bmartin@uhccux.uhcc.Hawaii.Edu (Brian Martin) Newsgroups: comp.sys.mac.apps Subject: Re: 4D Importing and Exporting Data (Merging databases) Keywords: merge, import, export (duplicate record problem) Message-ID: <10390@uhccux.uhcc.Hawaii.Edu> Date: 24 Nov 90 22:53:31 GMT References: <11775@hubcap.clemson.edu> Reply-To: martin@medix.pegasus.com (Brian K. Martin, M.D.) Organization: University of Hawaii Lines: 55 In article <11775@hubcap.clemson.edu> dragon@hubcap.clemson.edu (Michael E. Quattlebaum) writes: > ... Some of the data they have is likely to have the >same values for indexed fields (and thus 4D will not write that record). Michael, You have the "unique" attribute set for the indexed field. When you attempt to add a record which contains a vlaue for that field which duplicates a value already stored in another record, 4D rejects the attempted write, which is as it should be. The unique attribute should only be assigned to fields which are primary or alternate keys for the record, i.e., the field uniquely identifies the record in the file. If you are indeed trying to import duplicate records, as when you would update existing employee records with new sales information, then you need a custom import routine. The code off the top of my head would be something like: $docref:=open document ("ImportFile") Default file ([Employees]) receive packet ($docref; vEmpNum; FS) receive packet ($docref; vSales; FS) receive packet ($docref; vTerritory; RS) while (OK=1) search ([Employees]EmpNum=vEmpNum) if (Records in selection=0) Create record [Employees]EmpNum:=vEmpNum end if [Employees]Sales:=vSales [Employees]Territory:=vTerritory Save record receive packet ($docref; vEmpNum; FS) receive packet ($docref; vSales; FS) receive packet ($docref; vTerritory; RS) end while close document ($docref) Here, RS is the record separator that you define, and FS is the field separator that you define. Best regards, Brian K. Martin, M.D. Martin Information Systems, Ltd. 1103 9th Avenue, Suite 203 Honolulu, Hawai`i 96816-2403 Voice (808) 733-2003 Fax (808) 733-2011 INTERNET: martin@medix.pegasus.com, bmartin@uhccux.uhcc.hawaii.edu ARPA: uhccux!bmartin@nosc.MIL UUCP: {uunet,dcdwest,ucbvax}!ucsd!nosc!uhccux!bmartin