Re: Capitalizing First Letter of Every Word

From: "Thalis A(dot) Kalfigopoulos" <thalis(at)cs(dot)pitt(dot)edu>
To: "Brian T(dot) Allen" <brian(at)gzmarketing(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Capitalizing First Letter of Every Word
Date: 2001-06-26 23:05:29
Message-ID: Pine.LNX.4.21.0106261902280.27771-100000@aluminum.cs.pitt.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 26 Jun 2001, Brian T. Allen wrote:

> Hi *,
>
> I have a database of products, and the client entered everything in all caps. While there is no intelligent way to do change everything to what it should be, changing the first letter of every word to uppercase and everything else to lowercase would at least look better (except for the occasional acroynym).
>
> Is there a function to do that? I think I can handle everything except breaking the whole column up into individual words... I know how I would do it in PHP (and I may have to resort to that), but would prefer to do it in the db.
>
> Any suggestions?

try this:

UPDATE lala_table SET lala_col=initcap(lower(lala_col));

It will make the first letter of every word uppercase (close enough)

If not satisfied, you can do it by extracting the first character, capitalizing, and then lower()ing the rest of the message. Check http://www.postgresql.org/idocs/index.php?functions-string.html for char_length(),substring(),upper(),lower()

cheers,
thalis

>
> Thanks,
> Brian
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sergei Pohilko 2001-06-26 23:15:45 Cast varchar to interval in plpgsql
Previous Message Alex Knight 2001-06-26 23:04:22 Re: Capitalizing First Letter of Every Word