C-language example of using/returning numeric

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: C-language example of using/returning numeric
Date: 2002-09-16 11:47:25
Message-ID: 3D85C4CD.6090006@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Does anyone happen to have a server-side C-language example of
using the Version-1 calling conventions with the NUMERIC data
type? Is it possible? For example, instead of writing:

PG_FUNCTION_INFO_V1(add_one);

Datum add_one(PG_FUNCTION_ARGS)
{
int32 arg = PG_GETARG_INT32(0);
PG_RETURN_INT32(arg + 1);
}

I'd like to do the equivalent with NUMERIC. I see the
appropriate macros declared in utils/numeric.h. But I'm not sure
I understand the representation of NumericData:

varlen <- self-explanatory
n_weight <- ??
n_rscale <- scale of numeric
n_sign_dscale <- ??
n_data[1] <- ?? is this BCD?

Are there any helper functions available to the C-language
server-side developer wrt numeric?

Thanks for any tips,

Mike Mascari
mascarm(at)mascari(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message king 2002-09-16 12:11:24 Re: sum(if command
Previous Message CoL 2002-09-16 11:15:45 Re: sum(if command