Duplicate entries in database

Hi, I have a process model where we are doing write to data store twice. First is insert and other should be update on same record. We have a primary key ID which is primary key and set to auto increment. First insert has ID as 1 and other insert Id gets incremented to 2 so 2 entries are coming. Is this because whenever we hit the database 'ID' will get incremented as it is set to auto increment? Should I set it to not be auto incremented? Or is there a way to update the same record and ID should have value as 1 only for second entry in db?

  Discussion posts and replies are publicly visible

Parents
  • Hi there.

    If you are writing and updating in the same process model, you need to be sure to save back the results from the first write to data store node so that the process variable now has the database generated PK. You can do this on the outputs tab of the write to data store node, by setting the stored values output to save over your process variable. Otherwise, the PV will still have null  for the PK when you go to the second write to data store node, and will thus try and generate a new one.

Reply
  • Hi there.

    If you are writing and updating in the same process model, you need to be sure to save back the results from the first write to data store node so that the process variable now has the database generated PK. You can do this on the outputs tab of the write to data store node, by setting the stored values output to save over your process variable. Otherwise, the PV will still have null  for the PK when you go to the second write to data store node, and will thus try and generate a new one.

Children