-- Facts-Split-Undo.sql
/* 
2012-12-21 Tom Holden ve3meo
Reverses the changes made by Facts-SplitSharedToIndiv.sql
Requires tables zTmpShareSplit and WitnessTableSafe from the Split query

Deletes the new Indiv Share, Census and Residence events and 
related citations, media tags and webtags
and restores the Sharings. Sort of an UNDO... but not complete;
the appends to the original fact note remain.
*/

DELETE FROM EventTable WHERE EventID > (SELECT Maxrowid FROM zTmpShareSplit WHERE TableName LIKE 'EventTable');
DELETE FROM CitationTable WHERE CitationID > (SELECT Maxrowid FROM zTmpShareSplit WHERE TableName LIKE 'CitationTable'); 
DELETE FROM MediaLinkTable WHERE LinkID > (SELECT Maxrowid FROM zTmpShareSplit WHERE TableName LIKE 'MediaLinkTable'); 
DELETE FROM URLTable WHERE LinkID > (SELECT Maxrowid FROM zTmpShareSplit WHERE TableName LIKE 'URLTable'); 
-- To restore the Sharings:
INSERT INTO WitnessTable
SELECT * FROM WitnessTableSafe
;
