Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Sort (Collating Sequence)

RE: Sort (Collating Sequence)

From: Mercadante, Thomas F <NDATFM_at_labor.state.ny.us>
Date: Fri, 24 Jan 2003 04:55:09 -0800
Message-ID: <F001.005397BC.20030124045509@fatcity.com>


Laura,  

The way that I have always handled this was to create another column in the table, and populate it with a before insert/update trigger.  

In your case, I would create a VENDOR_SORT column and move the vendor_name column into this column. I have created a function to strip out all non-alpha fields (like single quotes, hyphens, spaces etc) that would screw up the sort order. This way, the VENDOR_SORT field always will return things in the correct order. Things like McDonald and Mc Donald, O'Reilly and OReilly, as well as te' Reille and Terelle would all come out together where they belong.  

hope this helps.  

Tom Mercadante
Oracle Certified Professional

-----Original Message-----
Sent: Thursday, January 23, 2003 4:25 PM To: Multiple recipients of list ORACLE-L

I have a question concerning a situation with our ORDER BY clauses. We have a vendor table which allows the user to input any case. Therefore we have 'Vendor' and 'VENDOR'. When using the ORDER BY clause it sorts VENDOR first and then Vendor. I need for the names to be sorted regardless of the capitalization. I know that we could have put an UPPER function on the input of this data to alleviate this problem, but the deed is done. I had suggested using the UPPER in the ORDER BY clause to always insure true alphabetizing but the thought was to have the database handle this instead of relying on the application.

I have found SQLCASE which works when I SELECT but not on the ORDER BY clause. Plus this is SQL*Plus only. I have researched the NLS parameters and read about binary sorts vs linguistic sorts as well as the different parameters available, but I did not see anything that could handle this situation systemically. I basically wanted to see how to add UPPER to an ORDER BY clause without having to actually code it.

Does anyone know if there is such a creature? My boss says that SQL Server has an option to do this, which immediately puts me on the defense and retort (in good humor of course) that I was sure Oracle did if Microsoft did!! I do not mind researching but I do not know anywhere else to look.

Thanks in advance for your replies,

Laura

--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Mercadante, Thomas F
  INET: NDATFM_at_labor.state.ny.us

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Jan 24 2003 - 06:55:09 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US