Re: how do I check for lower case

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Juliann Meyer <Julie(dot)Meyer(at)noaa(dot)gov>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: how do I check for lower case
Date: 2006-08-10 21:57:58
Message-ID: 1155247078.20252.172.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 2006-08-10 at 15:32, Juliann Meyer wrote:
> I have a table with a column, lets call it identifier, that is defined
> as varchar(8) that should never contain lower case letters. Its a large
> table. Is there a way to query the table to see if any values in this
> column are lower case and to get a list out? The user interface
> application that users use prevents them from adding an entry in lower
> case now, but didn't in earlier version.

You can also use the same upper / lower functions to make sure no lower
case stuff gets into the table at a later date:

test=> create table aaa (a text check (upper(a)=a));
CREATE TABLE
test=> insert into aaa (a) values ('ABC');
INSERT 2120799293 1
test=> insert into aaa (a) values ('ABC123');
INSERT 2120799294 1
test=> insert into aaa (a) values ('ABC12a3');
ERROR: new row for relation "aaa" violates check constraint "aaa_a"

viola!

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Oisin Glynn 2006-08-10 22:49:49 Re: how do I check for lower case
Previous Message Daryl Richter 2006-08-10 21:46:52 Re: how do I check for lower case