Re: Case Insensitive comparison - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Case Insensitive comparison
Date
Msg-id 200309242145.21087.josh@agliodbs.com
Whole thread Raw
In response to Case Insensitive comparison  ("George A.J" <jinujosein@yahoo.com>)
Responses Re: Case Insensitive comparison  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
jinujose,

> i am using postgresql 7.3.x. I am converting a database in MS SQL server to
> PostgreSQL.

Good luck to you!

> The main problems i am facing is that in sql server the text comparisons
> are case insensitive. how can i compare text case insensitive in postgresql
> without using an upper() or lower() function in both sides (=). Is there
> any option to set in postgresql? Is there any problem in overriding the =
> operator that compare text. ie droping the current operator = and creating
> a new = operator(text,text). Does the existing = operator is using
> internally by postgres for some porpose. please help

I would *not* suggest modifying such a fundamental operator; you are very 
likely to break something.

You can use "ILIKE" to compare text:
'Joe' ILIKE 'joE' == true

You can also use the "regex" operator:
'Joe' ~* '^jOE$' == TRUE
... but that takes more adaptation.

However, neither of the above approaches can be indexed.

> Another problem is in creating function...
> How can i create a function that accept and return any type. the type "any"
> is not allowing as parameter or return type. Is it possible? i want to
> create a function similar to NULLIF().

You can't, nor will you be able to -- in te future, some 7.4 functions will be 
able to *accept* any type, but they will still return a specific type.  
Instead, you need to create a seperate NULLIF() for each data type you're 
likely to use.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco


pgsql-sql by date:

Previous
From: "Kumar"
Date:
Subject: Large Objects and Bytea
Next
From: sad
Date:
Subject: Re: Large Objects and Bytea