// Verwijder mail die niet naar de testgroep gaat

var str = '..//oracle.udl'; // udlpath
var udlstr = 'File Name='+str;
var Oracle = new ActiveXObject("ADODB.Connection");
Oracle.Open(udlstr);

var sql = "ALTER SESSION SET nls_territory='AMERICA'";
var oRs = Oracle.Execute(sql)

sql =  "DELETE fac_notificatie n "
     + " WHERE NOT EXISTS " 
     + "     (SELECT DISTINCT gg.prs_perslid_key "
     + "        FROM fac_gebruikersgroep gg "
     + "       WHERE gg.prs_perslid_key = n.prs_perslid_key_receiver "
     + "         AND gg.fac_groep_key = 61 ) "
     + "  AND COALESCE(fac_notificatie_receiver_email, 'leeg') <> 'PNBQualogy@qualogy.com'";

oRs = Oracle.Execute(sql);

sql = "UPDATE fac_notificatie"
    + "   SET fac_notificatie_oms = SUBSTR('[TEST! U kunt dit bericht negeren] '||fac_notificatie_oms, 1, 2048)"
    + " WHERE fac_notificatie_oms NOT LIKE '[TEST! U kunt dit bericht negeren]%'"
    + "   AND COALESCE(fac_notificatie_receiver_email, 'leeg') <> 'PNBQualogy@qualogy.com';

oRs = Oracle.Execute(sql);