Re: Programmatic access to interval units

Поиск
Список
Период
Сортировка
От Nelson Green
Тема Re: Programmatic access to interval units
Дата
Msg-id CAGo-KZk+akGUc48zigitM7eAw+UzLt=5hX=e0_=8mbGFzfGAog@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Programmatic access to interval units  (Merlin Moncure <mmoncure@gmail.com>)
Ответы Re: Programmatic access to interval units  (Melvin Davidson <melvin6925@gmail.com>)
Re: Programmatic access to interval units  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
On Mon, Dec 1, 2014 at 2:14 PM, Merlin Moncure <mmoncure@gmail.com> wrote:
On Mon, Dec 1, 2014 at 10:42 AM, Nelson Green <nelsongreen84@gmail.com> wrote:
> Good morning list,
>
> According to the documentation for interval data type inputs, the unit can
> be one of microsecond, millisecond, second, minute, hour, day, week, month,
> year, decade, century, or millennium. Are these units stored in a catalog
> somewhere? I would like to access them programmatically if possible, to
> validate input for a function I am developing.

if you're writing C, you can use libpqtypes to do this. It exposes the
interval as a C structure.

typedef struct
{
        int years;
        int mons;
        int days;
        int hours;
        int mins;
        int secs;
        int usecs;
} PGinterval;


merlin

Thanks Merlin. I am not writing this in C, rather I am using Pl/pgSQL. Apologies
for not mentioning that up front. I was hoping to do a SELECT ... WHERE IN
query form a catalog relation.

That being said, maybe it is time for me to get back into C? I haven't done much
in C in many years, but this simple validation function might not be a bad
jumping off point. If I do not get the response I was hoping for I may just do
that.

Regards,
Nelson

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

Предыдущее
От: Tim Schäfer
Дата:
Сообщение: Auto vacuum not running -- Could not bind socket for statistics collector
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Auto vacuum not running -- Could not bind socket for statistics collector