Re: Set COLLATE on a session level

From: Dirk Mika <Dirk(dot)Mika(at)mikatiming(dot)de>
To: Karsten Hilbert <karsten(dot)hilbert(at)gmx(dot)net>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Set COLLATE on a session level
Date: 2020-11-30 10:11:38
Message-ID: 17384830-38E8-4F5C-92F9-338A1F1C6333@mikatiming.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> > pá 20. 11. 2020 v 15:28 odesílatel Dirk Mika <Dirk(dot)Mika(at)mikatiming(dot)de>
> > napsal:
> >
> > > Let's assume there is an app that accesses the same database from
> > > different countries. And in this app data should be displayed ordered. And
> > > the sort order is not identical in all countries.
> > >
> > > Does the app have to send different SQL commands depending on the country?
> > > Not nice.
> > > Do the data have to be sorted in the app? Not nice either.
> > >
> >
> > the query is the same - you just use a different COLLATE clause. For
> > Postgres there is not any other way.
>
> One might use a function producing a SELECT taking the locale as a parameter.
>
> Or views in schemas per locale. Selecting the search path
> per locale pulls in the right view.

Suppose the SQL statements are generated by a database layer such as Hibernate. It seems to me that it is not possible to use a function that adds the COLLATE clause.

And one view per locale would mean that I would have to create a whole schema including all views for each locale I want to support. I would have to roll out a new version of the data model, just for an additional locale.

This all seems unnecessarily complicated to me.

Dirk

--
Dirk Mika
Software Developer

mika:timing GmbH
Strundepark - Kürtener Str. 11b
51465 Bergisch Gladbach
Germany

fon +49 2202 2401-1197
dirk(dot)mika(at)mikatiming(dot)de
www.mikatiming.de

AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884
Geschäftsführer: Harald Mika, Jörg Mika

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karsten Hilbert 2020-11-30 10:56:23 Re: Set COLLATE on a session level
Previous Message Gustavsson Mikael 2020-11-30 06:59:37 SV: SV: Problem with pg_notify / listen