Re: Convert to upper

From: Peter Schindler <pschindler(at)synchronicity(dot)com>
To: Matthias Teege <matthias(at)mteege(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Convert to upper
Date: 2001-03-02 16:16:18
Message-ID: B0021451229@tellurian.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Matthias,

the easiest way is to use CHECK constraints. see example below.

Servus,
Peter

Matthias Teege wrote:
> is there any way to limit values to upper case strings?
> Somthing like:
>
> name char(15) DEFAULT (upper(name))
>
> or must I use triggers?

test=# create table bla(bb char(10) CHECK (bb =UPPER(bb)));
CREATE
test=# \d bla
Table "bla"
Attribute | Type | Modifier
-----------+---------------+----------
bb | character(10) |
Constraint: ((bb)::text = upper((bb)::text))

test=# insert into bla values ('OTTO');
INSERT 381409 1
test=# insert into bla values ('otto');
ERROR: ExecAppend: rejected due to CHECK constraint bla_bb
ERROR: ExecAppend: rejected due to CHECK constraint bla_bb
test=# select * from bla;
bb
------------
OTTO
(1 row)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2001-03-02 16:27:48 Re: Re: Want to learn the Postgresql database system
Previous Message Rod Taylor 2001-03-02 16:05:42 Re: Re: Convert to upper