1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
| CREATE FUNCTION public.SetMajLe()
RETURNS "trigger"
LANGUAGE 'plpgsql'
VOLATILE
AS
$$
begin
new.MajLe = now();
return new;
end;
$$
;
CREATE FUNCTION public.SetCreeLe()
RETURNS "trigger"
LANGUAGE 'plpgsql'
VOLATILE
AS
$$
begin
new.CreeLe = now();
new.MajLe = now();
return new;
end;
$$
;
-- Sequence: autonumidseq
CREATE SEQUENCE autonumidseq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1003461
CACHE 1;
ALTER TABLE autonumidseq OWNER TO postgres;
GRANT ALL ON TABLE autonumidseq TO postgres;
GRANT SELECT, UPDATE ON TABLE autonumidseq TO sigalebu;
-- Table: implantation
CREATE TABLE implantation
(
idimplantation integer NOT NULL DEFAULT nextval('autonumidseq'::regclass),
idlocalite integer NOT NULL DEFAULT 11,
rue character varying(50),
numeropolice character varying(10),
coordx character varying(10), -- coordonnée X (pour la cartographie)
coordy character varying(10), -- coordonnée Y (pour la cartographie)
secteurstatistique character varying(10), -- code du secteur statistique (pour la cartognaphie)
telephone character varying(15),
fax character varying(15),
commentaire text,
actif smallint NOT NULL DEFAULT (-1),
bufint integer,
bufstr character varying(20),
creele timestamp without time zone,
creepar character varying(20),
majle timestamp without time zone,
majpar character varying(20),
actifliste smallint DEFAULT (-1),
ordreliste character varying(20),
CONSTRAINT pkimplantation PRIMARY KEY (idimplantation),
CONSTRAINT cuimplantation UNIQUE (idimplantation)
)
WITH (
OIDS=FALSE
);
ALTER TABLE implantation OWNER TO postgres;
GRANT ALL ON TABLE implantation TO postgres;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE implantation TO sigalebu;
-- Index: implantationordreliste
CREATE INDEX implantationordreliste
ON implantation
USING btree
(ordreliste, rue);
-- Trigger: remplircreele on implantation
CREATE TRIGGER remplircreele
BEFORE INSERT
ON implantation
FOR EACH STATEMENT
EXECUTE PROCEDURE setcreele();
-- Trigger: remplirmajle on implantation
CREATE TRIGGER remplirmajle
BEFORE INSERT OR UPDATE
ON implantation
FOR EACH STATEMENT
EXECUTE PROCEDURE setmajle();
-- Table: creditbudgetaire
CREATE TABLE creditbudgetaire
(
idcreditbudgetaire integer NOT NULL DEFAULT nextval('autonumidseq'::regclass),
idallocationdebase integer NOT NULL,
idanneebudgetaire integer NOT NULL,
libellecredit character varying(250) NOT NULL,
montantinitial numeric(12,2),
totalvariations numeric(12,2) DEFAULT 0, -- Cumul des variations de crédit (ajustements, redistributions)
montantactualise numeric(12,2) DEFAULT 0, -- = MontantInitial - TotalVariations
checkdatemouvements date,
checkmouvements smallint,
bufint integer,
bufstr character varying(20),
creele timestamp without time zone,
creepar character varying(20),
majle timestamp without time zone,
majpar character varying(20),
commentaire text,
ordreliste character varying(20),
actifliste smallint DEFAULT (-1),
actif smallint NOT NULL DEFAULT (-1),
bufidcb character varying(20),
bufanneebudgetaire character varying(20),
bufidab character varying(20),
CONSTRAINT pkcreditbudgetaire PRIMARY KEY (idcreditbudgetaire),
CONSTRAINT cucreditbudgetaire UNIQUE (idcreditbudgetaire)
)
WITH (
OIDS=FALSE
);
ALTER TABLE creditbudgetaire OWNER TO postgres;
GRANT ALL ON TABLE creditbudgetaire TO postgres;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE creditbudgetaire TO sigalebu;
-- Index: creditallocationdebase
CREATE INDEX creditallocationdebase
ON creditbudgetaire
USING btree
(idallocationdebase);
-- Index: creditanneebudgetaire
CREATE INDEX creditanneebudgetaire
ON creditbudgetaire
USING btree
(idanneebudgetaire);
-- Index: creditordreliste
CREATE INDEX creditordreliste
ON creditbudgetaire
USING btree
(ordreliste, idcreditbudgetaire);
-- Trigger: remplircreele on creditbudgetaire
CREATE TRIGGER remplircreele
BEFORE INSERT
ON creditbudgetaire
FOR EACH ROW
EXECUTE PROCEDURE setcreele();
-- Trigger: remplirmajle on creditbudgetaire
CREATE TRIGGER remplirmajle
BEFORE INSERT OR UPDATE
ON creditbudgetaire
FOR EACH ROW
EXECUTE PROCEDURE setmajle(); |
Partager