-- View: mf.vu_maitrise_usage

-- DROP VIEW mf.vu_maitrise_usage;

CREATE OR REPLACE VIEW mf.vu_maitrise_usage AS 
 SELECT mf_parcelle.id_parcelle AS num_access, mf_parcelle.cleparc, mf_parcelle.code_insee, mf_parcelle.numr_parcelle, mf_parcelle.lieu_dit, mf_parcelle.surface, mf_parcelle.code_site, mf_parcelle.projet_acquisition, mf_parcelle.historisation, mf_acte_acquis.code_acte, mf_acte_acquis.natr_acte, mf_acte_acquis.date_acte, mf_acte_acquis.nom_notaire, mf_acte_acquis.maitrise_fonciere, mf_acte_acquis.prix_acquisition, mf_acte_acquis.origine_propriete, mf_acte_acquis.duree_conv, mf_acte_acquis.echeance_prevue
   FROM mf.parcelle mf_parcelle, ( SELECT mf_acte.code_acte, mf_acte.natr_acte, mf_acte.date_acte, mf_acte.nom_notaire, mf_acte.maitrise_fonciere, mf_acte.prix_acquisition, mf_acte.origine_propriete, mf_acte.duree_conv, mf_acte.echeance_prevue
           FROM mf.acte mf_acte
          WHERE mf_acte.maitrise_fonciere::text <> 'Acquisition'::text) mf_acte_acquis
  WHERE mf_parcelle.code_acte::text = mf_acte_acquis.code_acte::text
  ORDER BY mf_parcelle.cleparc;

ALTER TABLE mf.vu_maitrise_usage OWNER TO ludodo;
GRANT ALL ON TABLE mf.vu_maitrise_usage TO ludodo;
GRANT SELECT, REFERENCES, TRIGGER ON TABLE mf.vu_maitrise_usage TO cpnrc;

