drop view ld0v0a;

CREATE VIEW LD0V0A AS SELECT
PCCA.PNR,
PCCA.NAMN,
PCCA.ADRESS,
PCCA.COADR,
PCCA.POSTNR,
PCCA.ORT,
PCCA.HEMTEL,
PCCA.ARBTEL,
NVL(LD0P0A.KADRESS,' ') AS KADRESS,
NVL(LD0P0A.KCOADR,' ') AS KCOADR,
NVL(LD0P0A.KPOSTNR,' ') AS KPOSTNR,
NVL(LD0P0A.KORT,' ') AS KORT,
NVL(LD0P0A.KHEMTEL,' ') AS KHEMTEL,
NVL(LD0P0A.KUATDAT,' ') AS KUATDAT,
NVL(LD0P0A.KFLYKTING,0) AS KFLYKTING,
PCCA.CIVKOD,
PCCA.CIVDAT,
PCCA.MEDBSKAP,
PCCA.MEDBDAT,
NVL(LD0P0A.FODFORS,0) AS FODFORS,
NVL(LD0P0A.FODLAN,0) AS FODLAN,
NVL(LD0P0A.FODLAND,0) AS FODLAND,
NVL(LD0P0A.OMRADE,0) AS OMRADE,
NVL(LD0P0A.FOLKFORS,0) AS FOLKFORS,
NVL(LD0P0A.FOLKLAN,0) AS FOLKLAN,
PCCA.FOLKKOM,
NVL(LD0P0A.FOLKDAT,' ') AS FOLKDAT,
PCCA.AVREGORS,
PCCA.AVREGDAT,
PCCA.ADRSKYDD,
PCCA.HEMLIGTFN,
NVL(LD0P0A.LCHAVDR,0) AS LCHAVDR,
NVL(LD0P0A.HARHUSHALL,0) AS HARHUSHALL,
NVL(LD0P0A.AKTRAKN,0) AS AKTRAKN,
NVL(LD0P0A.KLIENTRAKN,0) AS KLIENTRAKN,
NVL(LD0P0A.RESURSRAKN,0) AS RESURSRAKN,
NVL(LD0P0A.UPDDAT,' ') AS UPDDAT,
NVL(LD0P0A.UPDSIGN,' ') AS UPDSIGN,
NVL(LD0P0A.KUPDDAT,' ') AS KUPDDAT,
NVL(LD0P0A.KUPDSIGN,' ') AS KUPDSIGN,
NVL(LD0P0A.KOMDEL,0) AS KOMDEL,
NVL(LD0P0A.BETJOMR,0) AS BETJOMR,
PCCA.NYCKKOD,
PCCA.FODDAT,
PCCA.KON,
NVL(LD0P0A.REFRAKN,0) AS REFRAKN,
PCCA.PERSTEL,
PCCA.MOBIL,
PCCA.FAX,
PCCA.EPOSTHEM,
PCCA.EPOSTARB,
PCCA.FODKOM,
PCCA.BOKOM,
PCCA.MODMAL,
PCCA.KOMSPRAK,
PCCA.ADRSPRAK,
PCCA.FONETNAMN,
PCCA.YRKE,
PCCA.SMEKNAMN,
PCCA.UTL_ADR,
PCCA.UTL_POSTADR,
PCCA.UTL_ADRLAND,
PCCA.TIDKOMM,
PCCA.GRUPP,
PCCA.EGENCIVKOD,
PCCA.EJAVIS,
PCCA.SAKNBOST,
PCCA.AVLDAT,
PCCA.SPRAKTEXT,
PCCA.LANDTEXT,
PCCA.ADRESSDAT,
PCCA.UTLANDTEXT,
NVL(LD0P0A.AVISFLAGDAT,' ') AS AVISFLAGDAT,
NVL(LD0P0A.KOMSPRAK2,0) AS KOMSPRAK2,
NVL(LD0P0A.KOMSPRAK3,0) AS KOMSPRAK3,
NVL(LD0P0A.INVANDAT,' ') AS INVANDAT,
NVL(LD0P0A.TOLKBEHOV,0) AS TOLKBEHOV,
NVL(LD0P0A.MINSIDA,0) AS MINSIDA,
NVL(LD0P0A.KUNDNUMMER,0) AS KUNDNUMMER,
NVL(LD0P0A.EJKATEGORISERING,0) AS EJKATEGORISERING,
NVL(LD0P0A.KONTAKTSATT,0) AS KONTAKTSATT,
NVL(LD0P0A.KONTAKTSIGN,' ') AS KONTAKTSIGN,
NVL(LD0P0A.KONTAKTDATUM,' ') AS KONTAKTDATUM
from ld0p0a,pcc.pccv0a pcca
where pcca.pnr=ld0p0a.pnr(+)
	and pcca.pnr <> ' ';

GRANT ALL ON ld0v0a TO ld0ROANV;
GRANT ALL ON ld0p0a TO PCC;


