-- Customer specific once-script RWSN#31141.

SET ECHO ON
SPOOL xRWSN#31141.lst
SET DEFINE OFF

-- RWSN#31141 vastgelopen workflowmeldingen afmelden
-- meldt lopende hoofdworkflow meldingen (status 5) af die geen lopende workflowstappen meer hebben.
-- status 1, 5, 6 = afgewezen, afgemeld, verwerkt
UPDATE   mld_melding
   SET   mld_melding_status = 5
 WHERE   mld_melding_key IN
               (SELECT   m.mld_melding_key
                  FROM   mld_melding m
                 WHERE   mld_melding_status NOT IN (1, 5, 6)
                         AND m.mld_melding_key = mld_melding_start_key
                         AND m.mld_melding_key NOT IN
                                  (SELECT   m.mld_melding_start_key
                                     FROM   mld_melding m
                                    WHERE   mld_melding_status NOT IN
                                                  (1, 5, 6)
                                            AND m.mld_melding_key !=
                                                  mld_melding_start_key));

COMMIT;

BEGIN adm.systrackscriptId('$Id$'); END;
/
SPOOL OFF
