summaryrefslogtreecommitdiff
path: root/configs/reverseepg.sql
blob: 01653ff945bc32de547ee48c1d9c3a08f02a8b54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
CREATE PROCEDURE reverseepg ()
BEGIN
/*
* channelmap zurücksetzen
*/
update channelmap set mergesp = 0;
/*
* events zurücksetzen Teil 1
*/
update
 events ev,
 (select distinct channelid from channelmap where source <> 'vdr' ) cm
set
 useid = masterid,
 updflg =
   case
    when ev.delflg = 'Y' then 'D'
    else 'I'
   end
where
 ev.source = 'vdr' and
 ev.channelid = cm.channelid;
/*
* events zurücksetzen Teil 2
*/
update
 events ev,
 (select distinct mergesp,merge,channelid,source from channelmap) cm
set
 useid = masterid,
 updflg =
   case
    when ev.delflg = 'Y' then 'D'
    when ev.source = 'vdr' then 'P'
    when ev.source != 'vdr' and merge > 1 then 'S'
    else 'A'
   end
where
 ev.source = cm.source and
 ev.channelid = cm.channelid;
END