Обсуждение: rejecting characters in a field

Поиск
Список
Период
Сортировка

rejecting characters in a field

От
Kenneth Gonsalves
Дата:
hi
i have a table with a varchar field called 'name'. I want postgres to
reject any insert with characters defined as illegal characters, for
example '*/^#'. How do i do this?
--
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.sourceforge.net
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

Re: rejecting characters in a field

От
Gnanavel Shanmugam
Дата:
add check constraint with following pattern
check(name !~ '[*/^#]')

with regards,
S.Gnanavel


> -----Original Message-----
> From: lawgon@thenilgiris.com
> Sent: Thu, 9 Jun 2005 12:36:31 +0530
> To: pgsql-sql@postgresql.org
> Subject: [SQL] rejecting characters in a field
>
> hi
> i have a table with a varchar field called 'name'. I want postgres to
> reject any insert with characters defined as illegal characters, for
> example '*/^#'. How do i do this?
> --
> regards
> kg
>
> http://www.livejournal.com/users/lawgon
> tally ho! http://avsap.sourceforge.net
> ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Re: [despammed] rejecting characters in a field

От
Andreas Kretschmer
Дата:
am  09.06.2005, um 12:36:31 +0530 mailte Kenneth Gonsalves folgendes:
> hi
> i have a table with a varchar field called 'name'. I want postgres to 
> reject any insert with characters defined as illegal characters, for 
> example '*/^#'. How do i do this?

With a RULE or a TRIGGER.


Regards, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net===    Schollglas Unternehmensgruppe    === 


Re: [despammed] rejecting characters in a field

От
Michael Glaesemann
Дата:
On Jun 9, 2005, at 4:18 PM, Andreas Kretschmer wrote:

> am  09.06.2005, um 12:36:31 +0530 mailte Kenneth Gonsalves folgendes:
>
>> hi
>> i have a table with a varchar field called 'name'. I want postgres to
>> reject any insert with characters defined as illegal characters, for
>> example '*/^#'. How do i do this?
>>
>
> With a RULE or a TRIGGER.

Or a CHECK constraint on the column.

Michael Glaesemann
grzm myrealbox com


Re: [despammed] rejecting characters in a field

От
Bruno Wolff III
Дата:
On Thu, Jun 09, 2005 at 09:18:09 +0200, Andreas Kretschmer <akretschmer@despammed.com> wrote:
> am  09.06.2005, um 12:36:31 +0530 mailte Kenneth Gonsalves folgendes:
> > hi
> > i have a table with a varchar field called 'name'. I want postgres to 
> > reject any insert with characters defined as illegal characters, for 
> > example '*/^#'. How do i do this?
> 
> With a RULE or a TRIGGER.

Using a check constraint would be better a better way to do this.


Re: [despammed] rejecting characters in a field

От
Andreas Kretschmer
Дата:
am  09.06.2005, um  3:29:15 -0500 mailte Bruno Wolff III folgendes:
> On Thu, Jun 09, 2005 at 09:18:09 +0200,
>   Andreas Kretschmer <akretschmer@despammed.com> wrote:
> > am  09.06.2005, um 12:36:31 +0530 mailte Kenneth Gonsalves folgendes:
> > > hi
> > > i have a table with a varchar field called 'name'. I want postgres to 
> > > reject any insert with characters defined as illegal characters, for 
> > > example '*/^#'. How do i do this?
> > 
> > With a RULE or a TRIGGER.
> 
> Using a check constraint would be better a better way to do this.

Yes, okay.


Regards, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net===    Schollglas Unternehmensgruppe    ===