Решили:
- остановить все почтовики везде
- очистить через АПМ Очередь/Отсылку/Прием полностью везде
- очистить все папки POST
- вручную через СМ вернуть всем документам (WI, WO) статус на время, с которого все началось во всех базах отдельно по истории изменения (документы будут отбираться скриптом)
Код:
select * from(
select
id,
(
select newstate from supermag.smdoclog l_vchera
where
l_vchera.id = l.id
and l_vchera.eventtime = (
select
max(eventtime)
from supermag.smdoclog l_v1
where
l_v1.id = l.id
-- and l.eventtime > to_date('20.04.2010 20:00:00', 'DD.MM.YYYY HH24:MI:SS') -- с этого времени
and l_v1.eventtime < to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- до этого времени
and newstate>-1
)
and recid = (
select
max(recid)
from supermag.smdoclog l_v4
where
l_v4.id = l.id
-- and l.eventtime > to_date('20.04.2010 20:00:00', 'DD.MM.YYYY HH24:MI:SS') -- с этого времени
and l_v4.eventtime < to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- до этого времени
and newstate>-1
)
and newstate>-1
) vchera_do_20,
(
select l_vchera.employee||' '||to_char(eventtime, 'DD.MM.YYYY HH24:MI:SS') from supermag.smdoclog l_vchera
where
l_vchera.id = l.id
and l_vchera.eventtime = (
select
max(eventtime)
from supermag.smdoclog l_v1
where
l_v1.id = l.id
-- and l.eventtime > to_date('20.04.2010 20:00:00', 'DD.MM.YYYY HH24:MI:SS') -- с этого времени
and l_v1.eventtime < to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- до этого времени
and newstate>-1
)
and recid = (
select
max(recid)
from supermag.smdoclog l_v4
where
l_v4.id = l.id
-- and l.eventtime > to_date('20.04.2010 20:00:00', 'DD.MM.YYYY HH24:MI:SS') -- с этого времени
and l_v4.eventtime < to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- до этого времени
and newstate>-1
)
) vchera_do_20_,
(
select newstate from supermag.smdoclog l_seichas
where
l_seichas.id = l.id
and l_seichas.eventtime = (
select
max(eventtime)
from supermag.smdoclog l_v2
where
l_v2.id = l.id
and l_v2.eventtime > to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- с этого времени
-- and l.eventtime < to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- до этого времени
and newstate>-1
)
and recid = (
select
max(recid)
from supermag.smdoclog l_v3
where
l_v3.id = l.id
and l_v3.eventtime > to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- с этого времени
-- and l.eventtime < to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- до этого времени
and newstate>-1
)
) segodnia,
(
select l_seichas.employee||' '||to_char(eventtime, 'DD.MM.YYYY HH24:MI:SS') from supermag.smdoclog l_seichas
where
l_seichas.id = l.id
and l_seichas.eventtime = (
select
max(eventtime)
from supermag.smdoclog l_v2
where
l_v2.id = l.id
and l_v2.eventtime > to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- с этого времени
-- and l.eventtime < to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- до этого времени
and newstate>-1
)
and recid = (
select
max(recid)
from supermag.smdoclog l_v3
where
l_v3.id = l.id
and l_v3.eventtime > to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- с этого времени
-- and l.eventtime < to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS') -- до этого времени
and newstate>-1
)
) segodnia_
from supermag.smdoclog l
where
eventtime > to_date('20.04.2010 19:20:00', 'DD.MM.YYYY HH24:MI:SS')
and l.doctype in ('WI', 'WO')
and l.docdate < '20.04.2010'
)
where vchera_do_20 <> segodnia
group by
id, vchera_do_20, segodnia
order by vchera_do_20