0

Copying data from one table to another with conditions attached

Hi,

Can anyone please offer me advice on the coding.

I have a csv file from our supplier with product information. This file changes regularly so there might be new lines or prices might be updated.
So the idea is that I have a Master table with all the current pricing data, and I'd upload the new price file to the SalesFile Table which has the same fields but contains the latest pricing.

In this example both tables contains 3 rows (ignoring the ID)
SKU
Cost
Description

So what I'd do is create a button and on click it would do the following:

Loop through each row on the SalesFile

If SalesFile.SKU is not in Master then add the row from Salesfile
else
If SalesFile.SKU is in Master only modify the row if Cost OR Description has changed.

after the loop has finished, delete all rows from SalesFile.

Thanks

2 replies

null
    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    Is a second table really necessary? When importing csv data, you can designate a field as a key. Ninox then automatically does the job of using that key field to find the the corresponding records in the table and in the file, comparing the values of the other fields, and gives a listing of the proposed changes and additions.

    • Adrian_G
    • 3 yrs ago
    • Reported - view

    You are right. I didn't realise I could do that. Thanks

Content aside

  • 3 yrs agoLast active
  • 2Replies
  • 490Views