constraining chars for all cols of a table

Поиск
Список
Период
Сортировка
От Gauthier, Dave
Тема constraining chars for all cols of a table
Дата
Msg-id 482E80323A35A54498B8B70FF2B879800482827264@azsmsx504.amr.corp.intel.com
обсуждение исходный текст
Ответы Re: constraining chars for all cols of a table  ("David Johnston" <polobo@yahoo.com>)
Re: constraining chars for all cols of a table  (Susan Cassidy <scassidy@edgewave.com>)
Список pgsql-general

Hi:

 

I have to constrain the chars used for table columns.  For example...

   create table foo (col1 text, col2 text, col3 text);

... where

    col1 has to be all uppercase, nothing but [A-Z]

    col2 has to be all lowercase [a-z] plus [0-9] is also allowed

    col3 can be mixed case plus [0-9] and sqr brackets (but nothing else).

 

I could put a check constraint on each/every table column, but that seems complicated and potentially slow.

 

I could do this check using the existing insert and update before triggers, but then I'd have to loop through all the columns and decide one by one how to

check them.  Again, slow and complicated.

 

Is there a better way?  Whatever I do, I'd have to be able to capture violations to provide informative feedback  to the users through the perl script that'll actually be doing the insert/update.

 

Thanks in Advance !

 

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

Предыдущее
От: Chris Browne
Дата:
Сообщение: Re: disable triggers using psql
Следующее
От: Vick Khera
Дата:
Сообщение: Re: Canceling a DELETE query