Question

How to update data in Database using last max value for each item

  • 19 July 2021
  • 1 reply
  • 23 views

Badge +3

HI there,

I have access to an API that returns flow data. The data is structured with a serial id (unique to each logger), ID (sequential, but only to each logger) and the data value (float).

The API would run every 12 hours and just would return the last 12 hours of data with overlaps. The API creators have suggested that by fetching the max ID for each serial number in the existing data I should be able to return the data from the api that doesn't already exist. There is no provision in the API to pass these values as a parameter so will be using FME to achieve this.

I could output the data from the api into a holding table and use a FeatureJoiner to the existing data so insert the new rows, but the static table will grow exponentially and I can see this becoming a huge problem in time.

Is there a way to grab the max ID for each serial number from the static table, fire this against the holding table and grab only the new values which are greater than the max(ID) for each serial no?

Cheers

Neil


1 reply

Userlevel 3
Badge +17

You could use the SQLExecutor to request the max(ID) from the database.

MySQL: select max(ID) from yourTable group by serial_id

 

Or write the last ID to a separate Table?

Reply