Compare records from two tables and make an action if there is or is not a match

Hello

I have the following scenario that I need help with.

I have an action with a Snowflake database that gets updated and new products. For each of the product retrieved I want to either update or create them in my products table in Glide Apps.

So I need to get the updated records from Snowflake and see if they exist in the Glide Apps table and update the record or otherwise insert the record.

Snowflake does not have the rowID of the Glide Apps table so I need to compare the records using the SKU which exists in both tables.

How should I go about this?

Ok so essentially the SKU is the unique identifier which is our key here.

I don’t use Glide apps so I will only be able to assist high level.

I’m not sure if you are running the snowflake update queries in MAKE or other ways. Anyway If you are running it in MAKE I would do this all in the same flow. From the update snowflake go right to step 2.

If you are not I would schedule a scenario to run as many frequently as needed to query the data base for last updated since the last run. So lets say you run the scenario every 1 hr.

SELECT *
FROM database
WHERE updatedAt >= DATEADD(hour, -1, CURRENT_TIMESTAMP)
ORDER BY updatedAt DESC;

now you get all the products updated in the last hour. (make sure you use an iterator and iterate through all rows retrieved)
Then the 2 scenarios meet up depending on how you update snowflake

step 2.
Then just use the SKUs to get row and either update or create in Glide depending if they exist or not.

Does this help @Makeithappen ?

2 Likes

Thank you for the information.

Unfortunately the glide action forces you to use the rowID of the Glide table as the unique ID to update a record. So I agree with your first step but the second step won’t work.

I think I have to add a step to get the records from glide apps too, and then try match them based on the SKU and then I will have the RowID to update a record of there is no match then to create a record.



If you refer to the screenshots the route for the SKU’s match works. But when they don’t match and it goes the alternative route, it inserts duplicate products into Glide Apps.

Exactly like I said in step 2.

In that case you need to use the get a row in glide.

Don’t use the fallback method use filters.

If it finds the row update

If it doesn’t find the row create

1 Like