[GENERAL] How to convert a double value to a numeric datum type in pgsql?

2014-02-23 Thread Felix . 徐
Hi all, I'm talking about the source code of pgsql and I want to know how the typing system works in pgsql. A few functions can help us do the type conversion, for example: Int32GetDatum -- convert a integer to a datum Float8GetDatum -- convert double to a datum cstring_to_text -- convert a

Re: [GENERAL] How to convert a double value to a numeric datum type in pgsql?

2014-02-23 Thread Pavel Stehule
hello you have to look to postgresql/src/backend/utils/adt/numeric.c functions - then you can call float8_numeric Numeric result = DatumGetNumeric(DirectFunctionCall1(float8_numeric, Float8GetDatum(dx)); regards Pavel 2014-02-24 7:45 GMT+01:00 Felix.徐 ygnhz...@gmail.com: Hi all, I'm

Re: [GENERAL] How to convert a double value to a numeric datum type in pgsql?

2014-02-23 Thread Pavel Stehule
2014-02-24 8:42 GMT+01:00 Felix.徐 ygnhz...@gmail.com: Thanks , I find another function called OidInputFunctionCall which can automatically generate a datum from a string for any data type, but seems it is not recommended in the comments. it is little bit different - and it needs a second