What is the best way to force character data to upper case

Started by Dennisabout 14 years ago3 messagesgeneral
Jump to latest
#1Dennis
dennis@kabonkulator.com

I am wondering what the best way is to force character data to a specific
case, like upper case for example. Is a trigger or rule the only option?
Would a check constraint be better or faster than using rules or triggers,
knowing that a check constraint puts the onus back on the client code to
ensure the data is in the correct case?

#2Chris Travers
chris.travers@gmail.com
In reply to: Dennis (#1)
Re: What is the best way to force character data to upper case

On Wed, Feb 1, 2012 at 10:09 PM, Dennis <dennis@kabonkulator.com> wrote:

I am wondering what the best way is to force character data to a specific
case, like upper case for example. Is a trigger or rule the only option?
Would a check constraint be better or faster than using rules or triggers,
knowing that a check constraint puts the onus back on the client code to
ensure the data is in the correct case?****

For something like this I would think triggers would be more robust and I
wouldn't expect the performance overhead to be that great.

Best Wishes,
Chris Travers

In reply to: Dennis (#1)
Re: What is the best way to force character data to upper case

On 02/02/2012 06:09, Dennis wrote:

I am wondering what the best way is to force character data to a
specific case, like upper case for example. Is a trigger or rule the
only option? Would a check constraint be better or faster than using
rules or triggers, knowing that a check constraint puts the onus back on
the client code to ensure the data is in the correct case?

Use the upper() function.

http://www.postgresql.org/docs/9.1/static/functions-string.html

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie