-- Customer specific once-script at migration to 5i (HOUT11).
--
-- (c) 2009 SG|facilitor bv 
-- $Revision$ 
-- $Id$
--
-- Support: +31 53 4800700
SET ECHO ON;
SPOOL xhout481to500.lst;
SET DEFINE OFF;

/* Formatted on 16-4-2010 15:56:16 (QP5 v5.115.810.9015) */
-- Bestel-catalogus 1041: Repro opdracht
-- Bestelling-kenmerk 1 : Opdrachtnummer Repro (= meldingnummer)
-- Vakgroepen 124 + 125 : Repro Amsterdam en Repro Rotterdam
UPDATE   bes_bestelling b
   SET   b.mld_melding_key =
            (SELECT   DISTINCT M.MLD_MELDING_KEY
               FROM   bes_bestelling_item bi,
                      ins_srtdeel sd,
                      ins_srtgroep sg,
                      bes_kenmerkbestell kb,
                      mld_melding m
              WHERE       BI.BES_BESTELLING_KEY = B.BES_BESTELLING_KEY
                      AND BI.INS_SRTDEEL_KEY = SD.INS_SRTDEEL_KEY
                      AND SD.INS_SRTGROEP_KEY = SG.INS_SRTGROEP_KEY
                      AND SG.INS_DISCIPLINE_KEY = 1041
                      AND BI.BES_BESTELLING_KEY = KB.BES_BESTELLING_KEY
                      AND KB.BES_KENMERK_KEY = 1
                      AND fac.safe_to_number (KB.BES_KENMERKBESTELL_WAARDE) =
                            M.MLD_MELDING_KEY
                      AND M.MLD_INS_DISCIPLINE_KEY IN (124, 125))
 WHERE   B.MLD_MELDING_KEY IS NULL;

COMMIT;

SPOOL OFF;

@hout.sql
