Merge DB4d patches (2/2)
svn path=/Database/trunk/; revision=60703
This commit is contained in:
130
CTR/CTR_VIE.SRC
130
CTR/CTR_VIE.SRC
@@ -86,7 +86,7 @@ AS
|
||||
CASE
|
||||
WHEN di.ins_deelsrtcontrole_status IN (2, 3)
|
||||
AND di.ins_deelsrtcontrole_datum_org IS NULL
|
||||
THEN -- Gestart(2) en de allereerste inspectie.
|
||||
THEN -- Gestart(2) en de allereerste inspectie (ins_deelsrtcontrole_datum_org is NULL).
|
||||
-- Periodieke taken:
|
||||
-- De startdatum is MAX(startdatum, aanmaakdatum/registratiedatum) en heeft altijd een waarde (ins_deel_aanmaak is altijd gevuld).
|
||||
-- Er is nog geen inspectie geweest en de startdatum is ingevuld of de registratiedatum ligt in de toekomst.
|
||||
@@ -120,29 +120,9 @@ AS
|
||||
xcp.ins_srtcontroledl_xcp_startdat
|
||||
ELSE
|
||||
fac.nextcyclusdate(
|
||||
-- er is nog geen inspectie geweest, dus de laatste inspectie is null
|
||||
COALESCE(
|
||||
(SELECT CASE xcp.ins_srtcontrole_mode
|
||||
WHEN 0
|
||||
THEN
|
||||
di.ins_deelsrtcontrole_datum_org
|
||||
ELSE
|
||||
idsc.ins_deelsrtcontrole_datum
|
||||
END
|
||||
ins_deelsrtcontrole_datum
|
||||
FROM ins_deelsrtcontrole idsc
|
||||
WHERE idsc.ins_srtcontrole_key =
|
||||
di.ins_srtcontrole_key
|
||||
AND di.ins_deelsrtcontrole_status IN (5, 6)
|
||||
AND idsc.ins_deel_key = di.deel_key
|
||||
AND idsc.ins_deelsrtcontrole_key =
|
||||
(SELECT MAX(idsc2.ins_deelsrtcontrole_key)
|
||||
FROM ins_deelsrtcontrole idsc2
|
||||
WHERE idsc2.ins_deel_key = di.deel_key
|
||||
AND idsc2.ins_srtcontrole_key =
|
||||
di.ins_srtcontrole_key
|
||||
AND idsc2.ins_deelsrtcontrole_status IN
|
||||
(5, 6)
|
||||
AND idsc2.ins_scenario_key = 1)),
|
||||
NULL,
|
||||
GREATEST(
|
||||
COALESCE(xcp.ins_srtcontroledl_xcp_startdat,
|
||||
xcp.ins_deel_aanmaak),
|
||||
@@ -152,108 +132,8 @@ AS
|
||||
xcp.ins_srtcontrole_eenheid,
|
||||
xcp.ins_srtcontrole_periode,
|
||||
xcp.ins_srtcontrole_bits,
|
||||
CASE
|
||||
WHEN xcp.ins_srtcontrole_mode = 1
|
||||
THEN
|
||||
1
|
||||
WHEN xcp.ins_srtcontrole_eenheid = 0
|
||||
AND TRUNC(
|
||||
COALESCE(
|
||||
(SELECT CASE xcp.ins_srtcontrole_mode
|
||||
WHEN 0
|
||||
THEN
|
||||
di.ins_deelsrtcontrole_datum_org
|
||||
ELSE
|
||||
idsc.ins_deelsrtcontrole_datum
|
||||
END
|
||||
ins_deelsrtcontrole_datum
|
||||
FROM ins_deelsrtcontrole idsc
|
||||
WHERE idsc.ins_srtcontrole_key =
|
||||
di.ins_srtcontrole_key
|
||||
AND di.ins_deelsrtcontrole_status IN
|
||||
(5, 6)
|
||||
AND idsc.ins_deel_key = di.deel_key
|
||||
AND idsc.ins_deelsrtcontrole_key =
|
||||
(SELECT MAX(
|
||||
idsc2.ins_deelsrtcontrole_key)
|
||||
FROM ins_deelsrtcontrole idsc2
|
||||
WHERE idsc2.ins_deel_key =
|
||||
di.deel_key
|
||||
AND idsc2.ins_srtcontrole_key =
|
||||
di.ins_srtcontrole_key
|
||||
AND idsc2.ins_deelsrtcontrole_status IN
|
||||
(5, 6)
|
||||
AND idsc2.ins_scenario_key =
|
||||
1)),
|
||||
xcp.ins_deel_aanmaak),
|
||||
'HH24') >=
|
||||
TRUNC(SYSDATE, 'HH24')
|
||||
THEN
|
||||
1
|
||||
WHEN xcp.ins_srtcontrole_eenheid > 0
|
||||
AND TRUNC(
|
||||
COALESCE(
|
||||
(SELECT CASE xcp.ins_srtcontrole_mode
|
||||
WHEN 0
|
||||
THEN
|
||||
di.ins_deelsrtcontrole_datum_org
|
||||
ELSE
|
||||
idsc.ins_deelsrtcontrole_datum
|
||||
END
|
||||
ins_deelsrtcontrole_datum
|
||||
FROM ins_deelsrtcontrole idsc
|
||||
WHERE idsc.ins_srtcontrole_key =
|
||||
di.ins_srtcontrole_key
|
||||
AND di.ins_deelsrtcontrole_status IN
|
||||
(5, 6)
|
||||
AND idsc.ins_deel_key = di.deel_key
|
||||
AND idsc.ins_deelsrtcontrole_key =
|
||||
(SELECT MAX(
|
||||
idsc2.ins_deelsrtcontrole_key)
|
||||
FROM ins_deelsrtcontrole idsc2
|
||||
WHERE idsc2.ins_deel_key =
|
||||
di.deel_key
|
||||
AND idsc2.ins_srtcontrole_key =
|
||||
di.ins_srtcontrole_key
|
||||
AND idsc2.ins_deelsrtcontrole_status IN
|
||||
(5, 6)
|
||||
AND idsc2.ins_scenario_key =
|
||||
1)),
|
||||
xcp.ins_deel_aanmaak),
|
||||
'DDD') >=
|
||||
TRUNC(SYSDATE, 'DDD')
|
||||
THEN
|
||||
1
|
||||
WHEN (SELECT CASE xcp.ins_srtcontrole_mode
|
||||
WHEN 0
|
||||
THEN
|
||||
di.ins_deelsrtcontrole_datum_org
|
||||
ELSE
|
||||
idsc.ins_deelsrtcontrole_datum
|
||||
END
|
||||
ins_deelsrtcontrole_datum
|
||||
FROM ins_deelsrtcontrole idsc
|
||||
WHERE idsc.ins_srtcontrole_key =
|
||||
di.ins_srtcontrole_key
|
||||
AND di.ins_deelsrtcontrole_status IN (5, 6)
|
||||
AND idsc.ins_deel_key = di.deel_key
|
||||
AND idsc.ins_deelsrtcontrole_key =
|
||||
(SELECT MAX(
|
||||
idsc2.ins_deelsrtcontrole_key)
|
||||
FROM ins_deelsrtcontrole idsc2
|
||||
WHERE idsc2.ins_deel_key = di.deel_key
|
||||
AND idsc2.ins_srtcontrole_key =
|
||||
di.ins_srtcontrole_key
|
||||
AND idsc2.ins_deelsrtcontrole_status IN
|
||||
(5, 6)
|
||||
AND idsc2.ins_scenario_key = 1))
|
||||
IS NULL
|
||||
THEN
|
||||
1
|
||||
ELSE
|
||||
0
|
||||
END,
|
||||
0) -- Er geldt dat (ctr_ismjob = 0), dus de eerste when is toch niet geldig.
|
||||
1, -- steps. De eerste inspectie is nog niet geweest dus 1 periode verder dan startdatum/aanmaakdatum.
|
||||
0) -- Er geldt dat (ctr_ismjob = 0)
|
||||
END
|
||||
END
|
||||
WHEN di.ins_deelsrtcontrole_status IN (2, 3)
|
||||
|
||||
Reference in New Issue
Block a user