pganon
This commit is contained in:
@@ -4,6 +4,7 @@ create extension if not exists postgis;
|
||||
create extension if not exists pgrouting;
|
||||
create extension if not exists vector;
|
||||
create extension if not exists pgcrypto;
|
||||
create extension if not exists pganon;
|
||||
|
||||
create table adherent (
|
||||
id int primary key,
|
||||
@@ -45,3 +46,13 @@ create table ligne (
|
||||
prix_unitaire decimal,
|
||||
quantite decimal
|
||||
);
|
||||
|
||||
create table fournisseur (
|
||||
id int primary key,
|
||||
fournisseur text not null
|
||||
);
|
||||
|
||||
create table region
|
||||
id int primary key,
|
||||
region text not null
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
ALTER TABLE famille
|
||||
ADD lft int, rgt int;
|
||||
ADD gauche int, droite int;
|
||||
|
||||
-- fonction auxiliaire récursive : reçoit le compteur 'n', retourne le compteur mis à jour
|
||||
CREATE OR REPLACE FUNCTION set_bounds(p_code INT, n INT)
|
||||
@@ -8,7 +8,7 @@ DECLARE
|
||||
child RECORD;
|
||||
BEGIN
|
||||
-- left
|
||||
UPDATE famille SET lft = n WHERE code = p_code;
|
||||
UPDATE famille SET gauche = n WHERE code = p_code;
|
||||
n := n + 1;
|
||||
|
||||
-- parcours des enfants
|
||||
@@ -19,7 +19,7 @@ BEGIN
|
||||
END LOOP;
|
||||
|
||||
-- right
|
||||
UPDATE famille SET rgt = n WHERE code = p_code;
|
||||
UPDATE famille SET droite = n WHERE code = p_code;
|
||||
n := n + 1;
|
||||
|
||||
RETURN n;
|
||||
@@ -34,7 +34,7 @@ DECLARE
|
||||
n INT := 1;
|
||||
BEGIN
|
||||
-- remise à zéro (optionnel)
|
||||
UPDATE famille SET lft = NULL, rgt = NULL;
|
||||
UPDATE famille SET gauche = NULL, droite = NULL;
|
||||
|
||||
-- pour chaque racine
|
||||
FOR root IN
|
||||
|
||||
Reference in New Issue
Block a user