insert into cible (ref_contact,ref_departement,ref_profil_societe,codecrea) (select distinct on (co.uid) co.uid, (select uid from departement where code='PDF' and ref_statut=0),(select uid from profil_societe where zid='PROSPECT'),'David Dupuis PDF from RES' from prospection p, employe e, cible c, departement d, contact co, travaille_pour t, societe s where p.ref_statut=0 and p.ref_employe=e.uid and p.ref_cible=c.uid and c.ref_statut=0 and c.ref_departement=d.uid and d.code='RES' and e.nom='Dupuis' and e.prenom='David' and co.uid=c.ref_contact and t.ref_personne_physique=co.uid and t.ref_societe=s.uid and (s.cp like '28%' or s.cp like '45%' or s.cp like '41%' or s.cp like '37%' or s.cp like '36%' or s.cp like '18%')); insert into prospection (ref_cible,ref_employe,codecrea) (select uid,(select uid from employe where prenom='David' and nom='Dupuis'),'David Dupuis pdf propections_clients.sql' from cible where codecrea='David Dupuis PDF from RES'); set client_encoding = 'latin-1'; insert into cible (ref_contact,ref_departement,ref_profil_societe,codecrea) (select distinct on (co.uid) co.uid, (select uid from departement where code='PDF' and ref_statut=0),(select uid from profil_societe where zid='PROSPECT'),'David Dupuis PDF from Boutard RES' from prospection p, employe e, cible c, departement d, contact co, travaille_pour t, societe s where p.ref_statut=0 and p.ref_employe=e.uid and p.ref_cible=c.uid and c.ref_statut=0 and c.ref_departement=d.uid and d.code='RES' and e.nom='Boutard' and e.prenom='François' and co.uid=c.ref_contact and t.ref_personne_physique=co.uid and t.ref_societe=s.uid and (s.cp like '8%' or s.cp like '21%' or s.cp like '58%')); insert into prospection (ref_cible,ref_employe,codecrea) (select uid,(select uid from employe where prenom='David' and nom='Dupuis'),'David Dupuis pdf propections_clients.sql' from cible where codecrea='David Dupuis PDF from Boutard RES');