Project

General

Profile

1 7289 leinfelder
/**
2
 * Correct generated System Metadata entries
3
 * 1. find system metadata with incomplete revision history
4
 */
5
6
-- these are old (obsoleted) entries that are not marked as such
7
select sm.guid, sm.obsoleted_by, sm.obsoletes, sm_by.guid as should_be_obsoleted_by
8
from systemmetadata sm, systemmetadata sm_by
9
where sm.guid = sm_by.obsoletes
10
and sm.obsoleted_by is null;
11
-- update them
12
BEGIN;
13
update systemmetadata sm
14
set obsoleted_by = sm_by.guid,
15
date_modified = now()
16
from systemmetadata sm_by
17
where sm.guid = sm_by.obsoletes
18
and sm.obsoleted_by is null;
19
--ROLLBACK;
20
COMMIT;
21
22
-- these are ones that should be marked as newer revisions
23
select sm.guid, sm.obsoleted_by, sm.obsoletes, sm_s.guid as should_obsolete
24
from systemmetadata sm, systemmetadata sm_s
25
where sm.guid = sm_s.obsoleted_by
26
and sm.obsoletes is null;