Jump to content
Sign in to follow this  
Toni

Importing without duplicating existing records

Recommended Posts

Hello

  I have a database which imports data from a csv file. This csv file is generated by a machine usually every day. But it does not delete previous data, it just generates the whole data it has on the same file (overwriting it). Obviously I don't want duplicated records in my database.

  The first solution was to actually delete the whole records and re-import them, but this wasn't the preferred solution.

  So I thought of a second solution which I would like to share for any advice.

  I created a second table, Table_B with same fields as in first table Table_A. Then added a relation between the two tables where Table_A::field_a = Table_B::field_a. Then created a calculation field in Table_B which is equal to Table_A::field_a (Table_B::field_related = Table_A::field_a). The import has two steps, first I import from csv into Table_B then I perform a find where Table_B::field_related is empty and then I import what is found in Table_B into Table_A.

  I remember I have read time ago, in this forum I believe, a similar solution with related tables but different approach. Can not find that post.

  Do you think this is a good approach or can something be done differently?

Share this post


Link to post
Share on other sites

Some more details would be useful. In general, if you want the import to update existing records, you can choose the Update matching records method when importing (see: https://fmhelp.filemaker.com/help/18/fmp/en/index.html#page/FMP_Help%2Fimporting-data.html%23ww1027874). Then there will be no need for elaborate post-processing of the imported data.

Share this post


Link to post
Share on other sites

Yes comment, that can be used too, but it would still involve a find on Table_A since the update matching records works on current found set. Beside, who knows, maybe in future it will not be needed to update the imported records because of possible editing of the records.

Share this post


Link to post
Share on other sites
2 hours ago, Toni said:

it would still involve a find

Isn't your import scripted? Surely the elaborate scheme you have described in your question would have to be scripted? As would be your current solution of deleting all existing records before importing new ones So the question you should be asking yourself is what is the simplest route to the desired goal. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.