how to extract and use a string like a constraint?

Поиск
Список
Период
Сортировка
От Jean-Yves F. Barbier
Тема how to extract and use a string like a constraint?
Дата
Msg-id 20100707221316.1fc01f98@anubis.defcon1
обсуждение исходный текст
Ответы Re: how to extract and use a string like a constraint?  (Thom Brown <thombrown@gmail.com>)
Список 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

В списке pgsql-novice по дате отправления:

Предыдущее
От: "John T. Dow"
Дата:
Сообщение: Re: Dropped table, no backup, restore from file system backup or WAL files?
Следующее
От: Tim Landscheidt
Дата:
Сообщение: Re: how to extract and use a string like a constraint?