Re: converting numeric to string in postgres code

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Szymon Guz <mabewlun(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: converting numeric to string in postgres code
Date: 2013-05-28 10:07:07
Message-ID: CAFj8pRDQLWJEed=By9GUdC_+hZFBvHLUUCyMH9VWnowHWvJMDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

2013/5/28 Szymon Guz <mabewlun(at)gmail(dot)com>:
> Hi,
> while hacking on some Postgres code I've found a problem.
>
> I need to convert numeric to string. I've got datum with numeric inside, so
> I'm getting it like:
>
> Numeric *numeric = DatumGetNumeric(d);
>
> but later I need to have string (most probably: const char *). I've found a
> couple of different ways for doing that, but I'm not aware of side effects.
>
> Which function/macro should I use?
>

There is a numeric_out function, you can use it or look on their source code

result = DatumGetCString(DirectFunctionCall1(numeric_out, d));

Regards

Pavel

> thanks,
> Szymon

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Szymon Guz 2013-05-28 10:09:31 Re: converting numeric to string in postgres code
Previous Message Szymon Guz 2013-05-28 10:02:18 converting numeric to string in postgres code