RE: Convert to upper - Mailing list pgsql-general

From Trewern, Ben
Subject RE: Convert to upper
Date
Msg-id 996802F75C3CD411B424001083FA445B059549@CET_PONXX_FP001
Whole thread Raw
In response to Convert to upper  (Matthias Teege <matthias@mteege.de>)
List pgsql-general

It may be better using a trigger.  You don't then get the error message (from the constraint) the record is just updated with the uppercase version of what was inserted.

Regards

Ben

> -----Original Message-----
> From: Peter Schindler [mailto:pschindler@synchronicity.com]
> Sent: 02 March 2001 16:16
> To: Matthias Teege
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] Convert to upper
>
>
> 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)
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to
> majordomo@postgresql.org)
>

pgsql-general by date:

Previous
From: "Mitch Vincent"
Date:
Subject: Re: Re: Convert to upper
Next
From: "Trewern, Ben"
Date:
Subject: RE: Does PostgreSQL support Constant Expression (Alias Name)?