Re: Normalize INTERVAL ouput format in a db driver

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: Normalize INTERVAL ouput format in a db driver
Дата
Msg-id D960CB61B694CF459DCFB4B0128514C202FF66AA@exadv11.host.magwien.gv.at
обсуждение исходный текст
Ответ на Normalize INTERVAL ouput format in a db driver  (Sebastien FLAESCH <sf@4js.com>)
Ответы Re: Normalize INTERVAL ouput format in a db driver
Список pgsql-general
Sebastien FLAESCH wrote:
> According to the doc, INTERVAL output format is controlled by
> SET intervalstyle.
>
> I am writing an interface/driver and need a solution to
> fetch/convert interval
> values independently from the current format settings...
>
> I could force my driver to implicitly set the intervalstyle
> to iso_8601, but I
> would prefer to leave this in the hands of the programmer...
>
> Imagine you have to write and ODBC interface/driver with
> libpq that must support
> the SQLINTERVAL C structure, how would you deal with
> PostgreSQL intervals?
>
> Is it possible to query the current intervalstyle?

You can use "SHOW intervalstyle" to get the current setting.

Would it be an option to use the to_char(interval, text)
function to convert the interval value to a string you can
understand? That would make you independent of server parameters.

Another way to go is to retrieve the interval values
in binary format. That would make you dependent on the
setting of "integer_datetimes", but it might still be easier.

Yours,
Laurenz Albe

В списке pgsql-general по дате отправления:

Предыдущее
От: Andreas Wenk
Дата:
Сообщение: Sugestion a db modele like mysql workbrench
Следующее
От: "Daniel Verite"
Дата:
Сообщение: Re: Feistel cipher, shorter string and hex to int