ecpg - char as host var

From: J(dot) Pablo González <disablez(at)disablez(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: ecpg - char as host var
Date: 2011-11-16 20:19:03
Message-ID: 000001cca49c$fc3f44c0$f4bdce40$@disablez.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I’m in the process of adding postgresql support to a big legacy program which stores small values in int8 (which is a typedef for a signed char).

However, when retrieving the value from a numeric(x) column , ecpg debug shows I get the correct value (e.g. 1), but in the int8 host variable I get the ascii value (49).

So basically the program goes like…

[.h file]

typedef char int8;

[.c file]

exec sql type int8 is char;

exec sql begin declare section;

int8 myvar;

exec sql end declare section;

exec sql select my_integer(1) column into :myvar from my_table;

And… I cannot change the int8 type (.h files are provided to me, structures cannot be modified), and there’s an epic amount of this cases so converting them all to use proper short ints for redaing/writing into the database would take too much time.

So… is there a decent solution to this ? So far I tried lying in the exec sql type sentence and telling that int8 is a short int… which somehow seems to work, but I wouldn’t want it to cause problems down the road.

Browse pgsql-novice by date

  From Date Subject
Next Message Johann Schatzer 2011-11-16 20:26:19 How to truncate? integers
Previous Message Baux David 2011-11-16 09:04:30 Re: