Issue with order by for type varchar

From: Simon_Kelly(at)moh(dot)govt(dot)nz
To: pgsql-general(at)postgresql(dot)org
Subject: Issue with order by for type varchar
Date: 2006-09-11 21:51:20
Message-ID: OF8586040B.B6512B99-ONCC2571E6.00776491-CC2571E6.00786173@moh.govt.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi All,

I am trying to order a select by the primary key which is a varchar field.

I have two known conditions,

1. the varchar always contains 28 characters. ( and, yes, I know the irony
of using a variable array on a known fixed length field )

2. the content of this field contains only the characters used in base 64
encoding.

However, when I do an order by I get misplacing of characters so character
sequences like "000+..." are coming after "0000....".

Is there any way of adding a function that would make the order by do
ordering on this field in the same way as the Java Collections.sort()
method?

Cheers

Simon

Simon Kelly
Java Developer
Information Systems Development
Information Technology Shared Services
Ministry of Health
DDI:
Mobile:

http://www.moh.govt.nz
mailto:Simon_Kelly(at)moh(dot)govt(dot)nz

****************************************************************************
Statement of confidentiality: This e-mail message and any accompanying
attachments may contain information that is IN-CONFIDENCE and subject to
legal privilege.
If you are not the intended recipient, do not read, use, disseminate,
distribute or copy this message or attachments.
If you have received this message in error, please notify the sender
immediately and delete this message.
****************************************************************************

*************************************************************************************
This e-mail message has been scanned for Viruses and Content and cleared
by the Ministry of Health's Content and Virus Filtering Gateway
*************************************************************************************

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Reyes 2006-09-12 02:02:12 Superuser lost access to particular database
Previous Message Scott Marlowe 2006-09-11 21:25:41 Re: Need Help w/ Timestamps