CONN#13583

svn path=/Customer/trunk/; revision=13492
This commit is contained in:
Arthur Egberink
2008-01-04 12:06:34 +00:00
parent bf2008afb0
commit 1143ff854b

View File

@@ -1,56 +1,44 @@
-- Afm#bestellingen.sql
--
--
SET ECHO ON
SPOOL xAfm#bestellingen.lst
PROMPT $Revision: 2 $
DECLARE
CURSOR c_cursor
IS
SELECT DISTINCT b.bes_bestelopdr_key
FROM bes_bestelopdr b, bes_bestelopdrstatuses s, prs_bedrijf be
WHERE be.prs_bedrijf_key = b.prs_bedrijf_key and (0=0)
AND b.bes_bestelopdr_status = s.bes_bestelopdrstatuses_key
AND b.bes_bestelopdr_key IN (
SELECT bes_bestelopdr_key
FROM bes_bestelling_item
WHERE bes_bestelling_key IN (
SELECT bes_bestelling_key
FROM bes_bestelling))
AND b.bes_bestelopdr_key IN (
SELECT bes_bestelopdr_key
FROM bes_bestelling_item
WHERE bes_bestelling_key IN (
SELECT bes_bestelling_key
FROM bes_bestelling
WHERE bes_bestelling_datum < sysdate - 40
AND bes_bestelling_status IN
(3, 4, 5)));
SELECT DISTINCT bo.bes_bestelopdr_key
FROM bes_bestelopdr bo, bes_bestelopdr_item boi, bes_bestelling_item bi, bes_bestelling b
WHERE bo.bes_bestelopdr_key = boi.bes_bestelopdr_key
AND boi.bes_bestelopdr_item_key = bi.bes_bestelopdr_item_key
AND bi.bes_bestelling_key = b.bes_bestelling_key
AND bes_bestelling_datum < sysdate - 40
AND bes_bestelling_status IN (3, 4, 5);
CURSOR c_cursor2 (pBestelopdr_key IN NUMBER)
IS
SELECT boi.bes_bestelopdr_item_key, bi.bes_bestelling_item_key
FROM ins_tab_discipline d,
ins_srtgroep g,
bes_mod_rep r,
ins_srtdeel s,
prs_bedrijf bd,
bes_bestelopdr b,
mld_adres m,
bes_bestelling_item bi,
bes_bestelopdr_item boi,
bes_bestelling bes
WHERE ( d.ins_discipline_module = 'REP'
OR d.ins_discipline_module = 'BES'
)
AND (0=0)
WHERE d.ins_discipline_module = 'BES'
AND d.ins_discipline_verwijder IS NULL
AND d.ins_discipline_key = g.ins_discipline_key
AND g.ins_srtgroep_key = s.ins_srtgroep_key
AND s.ins_srtdeel_key = bi.ins_srtdeel_key
AND s.ins_srtdeel_key = boi.ins_srtdeel_key
AND bi.bes_bestelling_key = bes.bes_bestelling_key
AND b.bes_bestelopdr_key = boi.bes_bestelopdr_key
AND bi.bes_bestelopdr_key = b.bes_bestelopdr_key
AND bi.bes_bestelopdr_item_key = boi.bes_bestelopdr_item_key
AND s.prs_bedrijf_key = bd.prs_bedrijf_key
AND m.mld_adres_key(+) = b.mld_adres_key_lev
AND r.bes_bestelling_item_key(+) = bi.bes_bestelling_item_key
AND b.bes_bestelopdr_key = pBestelopdr_key;
next_record c_cursor%ROWTYPE;
@@ -64,11 +52,11 @@ BEGIN
FOR next_record IN c_cursor LOOP
BEGIN
BEGIN
FOR next_record2 IN c_cursor2(next_record.bes_bestelopdr_key) LOOP
FOR next_record2 IN c_cursor2(next_record.bes_bestelopdr_key) LOOP
BEGIN
BEGIN
UPDATE bes_bestelopdr_item b
SET bes_bestelopdr_item_aantalontv = bes_bestelopdr_item_aantal
@@ -79,17 +67,17 @@ BEGIN
SET BES_BESTELLING_ITEM_AANTALONTV = bes_bestelling_item_aantal
WHERE bes_bestelling_item_key = next_record2.bes_bestelling_item_key;
EXCEPTION
WHEN OTHERS
THEN
oracle_err_num := SQLCODE;
oracle_err_mes := SUBSTR (SQLERRM, 1, 100);
v_errormsg :=
'(ORACLE error ' || oracle_err_num || '/' || oracle_err_mes
|| ')';
END;
EXCEPTION
WHEN OTHERS
THEN
oracle_err_num := SQLCODE;
oracle_err_mes := SUBSTR (SQLERRM, 1, 100);
v_errormsg :=
'(ORACLE error ' || oracle_err_num || '/' || oracle_err_mes
|| ')';
END;
END LOOP;
END LOOP;
END;
@@ -100,5 +88,5 @@ BEGIN
END;
/
SPOOL OFF