From: | "Jean-Yves F(dot) Barbier" <12ukwn(at)gmail(dot)com> |
---|---|
To: | "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | how to extract and use a string like a constraint? |
Date: | 2010-07-07 20:13:16 |
Message-ID: | 20100707221316.1fc01f98@anubis.defcon1 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Tim Landscheidt | 2010-07-07 20:31:50 | Re: how to extract and use a string like a constraint? |
Previous Message | John T. Dow | 2010-07-07 19:11:44 | Re: Dropped table, no backup, restore from file system backup or WAL files? |