Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Using Generic Comparator in Oracle ORDER BY
And ultimately, I did opt to use a custom PL/SQl function F that
translates inputs C1 as follows:
{C1, F(C1)} ==>
{
(A-1, A0001),
(A-1.1, A00010001),
(A-1.2, A00010002),
(A-1.2.1,A000100020001),
(B-1,B0001),
(B-2,B0002),
...
}
Not an altogether bad solution - it essentially translates C1 into a string that can be sorted lexically so
SELECT C1
FROM MY_TABLE
ORDER BY F(C1)
gives the desired results.
Notice, however, that my function would fail if I every received
"A-10000". It is also computationally more expensive than a direct
comparison function would have been. And finally, it just seems rather
obfuscous, IMO... it doesn't have the "elegant" feel that I would get
from a
"ORDER BY C1 COMPARING WITH F" construct... but then, maybe I'm just
weird that way.
Received on Wed Oct 26 2005 - 16:03:25 CDT