Skip to main content
Question

Update and Insert records in a Database

  • August 22, 2019
  • 2 replies
  • 196 views

nedwaterman
Contributor
Forum|alt.badge.img+9

Hi,

 

I have data coming on on a daily basis to a table with no ID field. The data is a volume recorded by a meter every 15 minutes. A user on here called @Takashi kindly helped to put the workspace together, which creates a volume every 15 minutes even if the data is missing (it adds a 0).

 

However, I did this on an INSERT statement and am now finding that new files are coming in that update the previous values. I didn't account for this. I need to alter my workspace to:

find if a record already exists

if the record exists and is not zero don't update the field

if the record doesn't exist add the data.

Any idea how I do this? I'm not sure whether to use a ChangeDetector, FeatureMerger or FeatureJoiner and so am a bit confused!

 

Thanks

Neil

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3701 replies
  • August 22, 2019

What database are you writing to?

If you're simply logging a reading every 15 minutes you shouldn't have to go through change detection (besides... without an ID field, what would you check for?). I think it could be remedied by setting up an ID field. An INSERT should create a new record every time then.


nedwaterman
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • 69 replies
  • August 22, 2019
Hi there,

 

I'm writing to SQL Server 2016. I'm not sure how setting up an ID field would work - the data doesn't come in with an ID field, which would only be created by the workflow. I'd have to check that the id of the Meter, and the datetime are the same, and if exist, and equal 0, ignore the record, otherwise insert it. Just not sure how to achieve this!