I've now read through your document. It would be a lot easier to answer you if you could attach (or send to Altova Support) your actual MTD file, but I will try based on your description and questions:
1. This is just a warning: your method for getting the sequence number by using MAX(remark_sequence) and adding 1 to it is dangerous. This is because if you have two drivers editing their records at the same time, they will get the very same sequence number
2. You are using "Go to Subpage event" command from your subpage. Without seeing your MTD file I can only guess that this was the actual error - you only need to Close Subpage, which will return you to your previous subpage, so try to remove the Go to Subpage.
3.
Quote:do we need add OriginalRowSet for the DB3 WHICH IS FINAL TABLE TO BE INSERT/EDIT?
- if you want to use the Save command, then yes
4.
Quote:HOW SYSTEM smart enough to do update
Save command uses Primary Key from your database to identify the record. I guess in your case SHIPMENT_GID is such a Primary Key. It then compares all other fields in a Row and OriginalRow with the same PrimaryKey. If any of the other fields changed - it will generate an UPDATE statements for those changed fields. If there is no OriginalRow with the same Primary Key - it will generate an INSERT statement
Now, if you have in $XML2 all fields from a DB3 Row, then you can implement the desired SAVE button instead of ADD/EDIT buttons this way:
Code:
If $XML2/Row/@REMARK_SEQUENCE = ''
Then
Reload $DB4
Update Node $XML2/Row/@REMARK_SEQUENCE...
Delete Node $DB3/DB/RowSet/Row[ @SHIPMENT_GID = $XML2/Row/@SHIPMENT_GID ]
Append Node $DB3/DB/RowSet...
Save $DB3
Reload $DB2
Close Subpage
What happens here - if it was an existing record, then you delete it from the RowSet first and it will be appended by the next Append Node command. If it is a new record, then you set new sequence number and append the node - the Delete Node will do nothing, because there is no existing record.
After all this Save will compare differences between RowSet and OriginalRowSet and propagate your changes to the database.
Important: you can do this trick with Delete Node/Append Node only if $XML2 contains all fields from $DB3 Row, otherwise you will lose some of the field values. If $XML2 does not have all the fields, then you need update every field in $DB3 Row instead of Delete/Append - let me know if I should help you to do this properly.
Altova MobileTogether Experts