SET application_name = 'HARDBOUNCES : mise a jour';

-- vidage de la table de travail
truncate general.hardbounce_tmp;

-- insert de la data dans la table de travail
copy general.hardbounce_tmp from '/var/scripts/flnetwork_hardbounces/hb.txt';

-- insertion des nouveaux enregistrements dans la table hardbounce
insert into general.hardbounce (hardbounce_email, hardbounce_md5, hardbounce_source)
select hardbounce_tmp_email, md5(lower(hardbounce_tmp_email)), 'flinteractive'
from general.hardbounce_tmp t
left outer join general.hardbounce h on t.hardbounce_tmp_email = h.hardbounce_email
where h.hardbounce_email is null;

