pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: George A.J <jinujosein@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: Case Insensitive comparison
Date: Wed, 24 Sep 2003 21:45:21 -0700
Message-ID: <200309242145.21087.josh@agliodbs.com> (raw)
In-Reply-To: <20030925033550.35699.qmail@web14915.mail.yahoo.com>
References: <20030925033550.35699.qmail@web14915.mail.yahoo.com>

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



view thread (9+ messages)  latest in thread

Message-ID: <200309242145.21087.josh@agliodbs.com>
Permalink:  ../200309242145.21087.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200309242145.21087.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, jinujosein@yahoo.com
  Subject: Re: Case Insensitive comparison
  In-Reply-To: <200309242145.21087.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox