I have 2 MS SQL tables, that I access through VFP using remote views.
Parent table
ID - Unique ID Field (default value at SQL level is NEWID())
Name - Name
Child Table
ID - Unque ID Field
Name - Name
FKParentID - ID from Parent.
In VFP, using my remote views, with buffering, I would like to insert a record into the parent table, then insert multiple records into the child table, but if there is a problem with a record in the child table, be able to revert all changes in both the child and parent table.
What I'm finding is that the ID field in the parent table can only be used in the insert of the child table (FkParentID field) if the parent table has been updated, (because of being a Unique ID type field). Therefore I am not able to revert the Parent table if there is a problem inserting records into the child table.
Is there anyway to handle this situation?
I tried using SQLSETPROP (setting to manual transactions) and then using SQLROLLBACK to revert, but it doesn't seem to work with Remote Views (buffering is set to 3).
Another option would be to remove the NEWID() as the default value and determine my own ID, but this could cause issues elsewhere.
Can anyone offer any other suggestions? Any help would be much appreciated.
Parent table
ID - Unique ID Field (default value at SQL level is NEWID())
Name - Name
Child Table
ID - Unque ID Field
Name - Name
FKParentID - ID from Parent.
In VFP, using my remote views, with buffering, I would like to insert a record into the parent table, then insert multiple records into the child table, but if there is a problem with a record in the child table, be able to revert all changes in both the child and parent table.
What I'm finding is that the ID field in the parent table can only be used in the insert of the child table (FkParentID field) if the parent table has been updated, (because of being a Unique ID type field). Therefore I am not able to revert the Parent table if there is a problem inserting records into the child table.
Is there anyway to handle this situation?
I tried using SQLSETPROP (setting to manual transactions) and then using SQLROLLBACK to revert, but it doesn't seem to work with Remote Views (buffering is set to 3).
Another option would be to remove the NEWID() as the default value and determine my own ID, but this could cause issues elsewhere.
Can anyone offer any other suggestions? Any help would be much appreciated.