Re: numeric data type

From: Juan Pablo L(dot) <jpablolorenzetti(at)hotmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: numeric data type
Date: 2015-09-22 20:26:50
Message-ID: DUB130-W16828E92299C7C4F47BC34D9450@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

thank you for your answer, the function is declared as:

FUNCTION wtt_discount_account(IN in_phonenumber varchar(20),IN in_balanceid integer,IN in_chgval numeric(10,2))

i chose numeric because is supposed to be better for numbers/money operations, supposed to be exact,
i would not want to loose precision because that is money, is there any other way which does not
involve loosing precision ? thankS!!

> From: tgl(at)sss(dot)pgh(dot)pa(dot)us
> To: jpablolorenzetti(at)hotmail(dot)com
> CC: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] numeric data type
> Date: Tue, 22 Sep 2015 16:07:36 -0400
>
> "Juan Pablo L." <jpablolorenzetti(at)hotmail(dot)com> writes:
> > Hi, i m writing a C module (extension), the procedure has a parameter that is of type numeric,
> > inside the function i can not read the parameter or so it seems, this what is do:
>
> > float8 db_balance,in_chgval;
>
> > in_chgval = PG_GETARG_FLOAT8(2);
>
> > elog(INFO,"in_chgval = %0.2f",in_chgval);
>
> If the C code is written that way, the function has to be declared to take
> type float8 (a/k/a double precision), not numeric.
>
> The parser will insert a conversion from numeric to float8 automatically,
> so the function will still work with a numeric data column. You might
> lose some precision in the conversion though.
>
> regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2015-09-22 21:11:26 Re: numeric data type
Previous Message Tom Lane 2015-09-22 20:07:36 Re: numeric data type