Getting a primitive numeric value from "DatumGetNumeric"?

Поиск
Список
Период
Сортировка
От Demitri Muna
Тема Getting a primitive numeric value from "DatumGetNumeric"?
Дата
Msg-id A3E2B8BE-7EE5-4555-90D8-09C832F7B558@demitri.com
обсуждение исходный текст
Ответы Re: Getting a primitive numeric value from "DatumGetNumeric"?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi,

I’m writing a C extension for PostgreSQL. One possible input datatype for my function is a numeric array, e.g.
ARRAY[[1.5,2.5],[3.5,4.5]].I can use “DatumGetNumeric” to extract a “Numeric” data type from the data, but at some
pointI need to convert this to a number (e.g. double) so that I can do mathy things with it. How does one convert a
“Numeric”to, say, a double? 

I have a workaround in that I can pass this to my function:

ARRAY[[1.5,2.5],[3.5,4.5]]::float8[]

but I’d rather have the code do that instead of bothering the user to remember that.

Thanks,
Demitri

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

Предыдущее
От: yeli
Дата:
Сообщение: Re: Crear Una FUNTION usando ROW_NUMBER
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Getting a primitive numeric value from "DatumGetNumeric"?