Hi listers,
I've got a table that describes a field and its constraint, but I don't
have any clue about how to extract and use this constraint as if it was on
a regular field line:
CREATE TABLE tstfld (
id serial primary key,
fieldtype VARCHAR(128) NOT NULL CHECK(char_length(fieldtype) > 2),
length SMALLINT DEFAULT NULL,
chk TEXT DEFAULT NULL
) WITHOUT OID;
INSERT INTO tstfld VALUES (
default,
'CHAR',
2,
E'CHECK((char_length(fieldtype) = 2) AND (fieldtype ~ ^\\d{2}::text))'
);
and I also don't understand why this don't work:
SELECT char_length(SELECT chk FROM tstchk WHERE id=1);
Can it only be use with a temp var into a proc?
--
Outside of a dog, a book is a man's best friend. Inside a dog it's too
dark to read. - Groucho Marx