Обсуждение: Calculations With NUMERIC Data Type In C Program

Поиск
Список
Период
Сортировка

Calculations With NUMERIC Data Type In C Program

От
"asergioz"
Дата:
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 pre�o do mercado! R$ 14,90 nos 3 primeiros meses! 
ASSINE AGORA! http://www.bol.com.br/acessobol/




Re: Calculations With NUMERIC Data Type In C Program

От
Michael Meskes
Дата:
On Sat, Jun 23, 2001 at 06:16:48PM -0300, asergioz wrote:
> ...
> 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.
> ... 
> EXEC SQL BEGIN DECLARE SECTION;
> numeric(17, 7)     var_1;
> numeric(17, 7)     var_2;
> long               key = 123;
> EXEC SQL END DECLARE SECTION;

I do not know that there is a numeric datatype in C. The datatype's given in
the declare section have to be C types.

> Please, does the ECPG interface work
> with variables of the NUMERIC data
> type, as shown above?

If you can map them to a C datatype yes.

> If not, what are the alternatives?

This is the same problem you run into with any embedded SQL preprocessor
there is.

Michael
-- 
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!


Re: Re: Calculations With NUMERIC Data Type In C Program

От
"asergioz"
Дата:
Ok, I'll look for another solution. 

Thank you very much.

Regards,

Antonio Sergio

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