Modify existing data in table when importing from XML

TiwazTiwaz Member Posts: 98
Hi everyone :)
I created an XMLPort which imports data from XML to a table in my table.
It only adds new lines in table when importing which is fine until it tries to import an entry from XML which has the same Serial No. (primary key) as an entry in my table when it returns error.
I want to add CONFIRM window and modify existing data.
For example, I have Car Serial No., Model and License Plates fields in my table.
When I import a car with same serial no. but different License plates it returns error since it tries to add new line.
I hope you get what I need :)
THANKS!

Best Answer

Answers

  • SowkarthikaSowkarthika Member Posts: 102
    You can write your code in OnBeforeInsertRecord function in XML port to check if the Serial No. exists already. If the Serial No. exists then you can choose to skip the record by using currXMLport.SKIP or you can write a code to modify the record.
  • edoderooedoderoo Member Posts: 89
    Apparently the serial no. is not unique, and therefor not the right choice for a primary key. Either you need to extend the primary key with the brand of the car, or the license-plate, but this will influence existing code that works with the file!
    You can also force the primary key to be unique by adding a consecutive number as primary key, and use the serial no. as secondary key.
    IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;
Sign In or Register to comment.