Hello.
Here is an extract from my database definition:
CREATE TABLE information (
fieldName text NOT NULL CHECK (fieldName <> ''),
code char NOT NULL CHECK (code <> ''),
label text,
PRIMARY KEY (fieldName, code)
);
-- Filling the table "information"
COPY information FROM stdin;
station.type H hydrological
parameter.type Q discharge
...
\.
-- Function that checks a field value is in the table "information".
CREATE FUNCTION checkInfo(text, char) RETURNS bool AS
'SELECT $2::char IN (SELECT code FROM information WHERE fieldName = $1::text)'
LANGUAGE 'sql';
-- A table using checkInfo
CREATE TABLE station (
code text NOT NULL,
type char NOT NULL,
name text,
longitude text,
latitude text,
altitude float,
PRIMARY KEY (code),
CONSTRAINT stationCodeNotEmpty
CHECK (code <> ''),
CONSTRAINT existingStationType
CHECK (verifierInfo('station.type', type))
);
As you can guess, the definition order is an important point.
But when I use pg_dumpall, it produces a script that don't respect the order. So I can't use this script to restore the database.
And the question is: Is there a better way to do what I want (checking field values from different tables against data in one table) that allow pg_dumpall to works ?
Thanks.
Guillaume Perréal - Stagiaire MIAG
Cemagref (URH), Lyon, France
Tél: (+33) 4.72.20.87.64