Calculations With NUMERIC Data Type In C Program

From: "asergioz"<asergioz(at)bol(dot)com(dot)br>
To: meskes(at)postgresql(dot)org
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Calculations With NUMERIC Data Type In C Program
Date: 2001-06-23 21:16:48
Message-ID: GFEJ40$IU7aID1OUL95Qhp01ld2BTVWg9rAX7Nu4N@bol.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi,

I have experience in developing
commercial software with the C
language and embedded SQL statements,
but I am new to
PostgreSQL. I need to perform several
calculations, in a C program, with
data returned from lots of fields of
the NUMERIC (17, 7)
data type.

For example:

EXEC SQL BEGIN DECLARE SECTION;
numeric(17, 7) var_1;
numeric(17, 7) var_2;
long key = 123;
EXEC SQL END DECLARE SECTION;

EXEC SQL
SELECT FIELD_1 INTO :var_1,
FIELD_2 INTO :var_2
FROM MYTABLE
WHERE THEKEY = :key;

var_1 += var_2 * 1.05;

...

/* After many calculations with */
/* var_1 and var_2, subjected */
/* to complex decision conditions. */

EXEC SQL
UPDATE MYTABLE
SET FIELD_1 = :var_1,
FIELD_2 = :var_2
WHERE THEKEY = :key;

Please, does the ECPG interface work
with variables of the NUMERIC data
type, as shown above?
If not, what are the alternatives?

I looked up in all the documentation
and the mailing lists but didn't find
an answer.

Thank you very much.

Regards,

Antonio Sergio


__________________________________________________________________________
Acesso pelo menor preo do mercado! R$ 14,90 nos 3 primeiros meses!
ASSINE AGORA! http://www.bol.com.br/acessobol/

Browse pgsql-interfaces by date

  From Date Subject
Next Message Cedar Cox 2001-06-24 09:35:51 Re: passing Windows NT user name to postgres triggers for logging
Previous Message Ana Carolina Alonso de Armiño 2001-06-22 19:36:06 JDBC interface