Re: [JDBC] Selecting Varchar range (through JDBC).

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Daryl Beattie <dbeattie(at)insystems(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: [JDBC] Selecting Varchar range (through JDBC).
Date: 2002-09-10 15:58:14
Message-ID: 20020910085321.W24828-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc


On Tue, 10 Sep 2002, Daryl Beattie wrote:

> Really? The collating elements are locale-specific?!? They are actually
> hard-coded somewhere??

It's part of the locale definition AFAIK. Some languages have/had
multi-character elements that have a particular sorting position that's
different than the individual characters.

> If this is so, and this is what is meant by the definition of a collating
> element, then I am going about things the entirely wrong way when trying to
> select a varchar range. In which case I would be tempted to do something
> like this instead:
>
> testdb=# select 'test' ~* '^[[.a.]-[.z.]][[.a.]-[.a.]]';
> [same as]
> testdb=# select 'test' ~* '^[a-z][a-a]';
>
> Of course, this won't match aa-za, because it won't match ab, ac, ..., az,
> bb, bc, ..., etc.
>
> So, does anybody have any advice on how to select a range?

Umm, I'd say use an or condition for the pieces, maybe like:
^([a-y][a-z]|za)
(if the last had more than a-a you'd need a character set there)

That's a little ugly, but should work.

> Stephan, thanks for clearing me up on the collating elements. Perhaps it
> should be in the docs that they are locale-specific ... so that simpletons
> like me won't be misled into thinking that they can just make up collating
> elements as they seem fit.

That might be a good idea, yeah.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2002-09-10 16:09:13 Re: describe table query?
Previous Message Daryl Beattie 2002-09-10 15:45:52 Re: [JDBC] Selecting Varchar range (through JDBC).

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Wall 2002-09-10 16:05:08 Re: Blobs and "No results were returned by the query."
Previous Message Daryl Beattie 2002-09-10 15:45:52 Re: [JDBC] Selecting Varchar range (through JDBC).