Re: german sort is wrong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reinhard Asmus wrote
> 
> when i make the same thing in oracle i've got
> 
> Ätna
> Anton
> ....
> 
> is it possible to get the same with postgresql and when how?
> 
> 

PostgreSQLs collation support is not complete. Until now, you can not define
a sort order of your own.

Workaround: 

Step1: Define a function like this

  CREATE OR REPLACE FUNCTION germanorder(text)
    RETURNS text AS
  $BODY$ SELECT
REPLACE(REPLACE(REPLACE(REPLACE(lower($1),'ß','ss'),'ä','ae'),'ö','oe'),'ü','ue')
$BODY$
    LANGUAGE sql VOLATILE
    COST 100;
  ALTER FUNCTION prisorder(text)
    OWNER TO postgres;

step2:  Create an functional index
 ( http://www.postgresql.org/docs/7.3/static/indexes-functional.html )
CREATE INDEX bezeichnung_germanorder_idx ON test1 (germanorder(col1));

step3: Select using the function
select * from sgvs.test order by germanorder(bezeichnung);

and you will get what you want...

If speed does not matter you can omit step2.

regards



--
View this message in context: http://postgresql.1045698.n5.nabble.com/german-sort-is-wrong-tp5582836p5590321.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.

-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux