I have a table of sales order lines (sDetail); There is an index on the records which is effectively a candidate index with a key of the Order reference plus STR( line number). This is used for retrieving the lines of a particular order.
There is also a primary index on the sDetail table which is a sequential ID.
The order may be amended. If an Order Line is deleted by the user I mark the record as deleted in this table; When I am processing I generally run with SET DELETED ON, so the user does not see these deleted records.
If however he re-creates the line, I am liable to create an error ‘Uniqueness of index is violated’ I understand that. To avoid creating this error, I can see two possible approaches :
Either : Include a filter expression on the index ‘FOR !DELETED()’ so that these records are invisible at run time
Or : When I wish to test for the existence of a record for a particular line, SET DELETED OFF, test for the existence of the record, and RECALL it if necessary. Then revert to SET DELETED ON.
What do other developers do? Or is there a better way?
Thank you