Re: Convert to upper

From: "Rod Taylor" <rod(dot)taylor(at)inquent(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Convert to upper
Date: 2001-03-02 18:49:13
Message-ID: 029001c0a349$79b74d50$6500000a@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

RE: [GENERAL] Convert to upperWhy not just do:

INSERT INTO TABLE (uppercase_value) VALUES (upper('value'));

Leave in the check, and all problems are solved without overhead of a trigger. Simple checks like the one shown don't have any noticeable speed loss. Trigger overhead does no matter how small the operation its doing.
--
Rod Taylor

There are always four sides to every story: your side, their side, the truth, and what really happened.
----- Original Message -----
From: Trewern, Ben
To: pgsql-general(at)postgresql(dot)org
Sent: Friday, March 02, 2001 12:35 PM
Subject: RE: [GENERAL] Convert to upper

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(at)synchronicity(dot)com]
> Sent: 02 March 2001 16:16
> To: Matthias Teege
> Cc: pgsql-general(at)postgresql(dot)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(at)postgresql(dot)org)
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martin A. Marques 2001-03-02 19:04:47 Re: SERIAL values
Previous Message Rod Taylor 2001-03-02 18:47:22 Re: Re: Thought on OIDs