Hi Shesh, thanks for your quick answer.
The usage context is with our Genero runtime system (www.4js.com), using our Informix driver/interface, written in ESQL/C.
The code is quite complex and I would need some time to write a simplified ESQL/C sample.
However, I have tested different binding combinations (as we obviously support different SQL types like CHAR/VARCHAR/LVARCHAR and have different Genero BDL variable types CHAR/VARCHAR/STRING):
I confirm that when fetching an LVARCHAR into a C buffer (with fixed size memory allocated) and binding with sqlvar.sqltype = CVCHARTYPE or CCHARTYPE, the conversion is done as expected. This occurs when the target Genero/BDL variable is a CHAR(size) or VARCHAR(size) with a known size (memory is already allocated)
However, we have a proprietary STRING type in our language, with no theoretical max size. When fetching SQL CHAR or VARCHAR, we can get the max size from the descriptors (sqlvar.sqllen) and we can allocate the target buffer, but when the source SQL type is LVARCHAR, we use ifx_var_getdata() to get the string and then do a copy...
Summary:
If you confirm that binding with CLVCHARPTRTYPE does not do any charset conversion and that this is a feature rather than a bug, we would need another type id that does the conversion. However, this looks more like a bug.
Would a binding with CVCHARTYPE do the job? Assuming that there is no size limitation issue, since the SQL type VARCHAR() is limited to 255 bytes?
------------------------------
Sebastien FLAESCH
------------------------------
Original Message:
Sent: Wed February 10, 2021 07:31 AM
From: Sheshnarayan Agrawal
Subject: ESQL/C: Fetching LVARCHAR with ifx_var_getdata() when DB and client locale do not match
Hi Sebastien,
It appears that since bind type is pointer (CLVCHAR*PTR*TYPE), it doesn't go through possible conversion. Could you try with VARCHAR or any other suitable binding? Also, it would be good, if you could provide small testcase to understand the problem better.
Thanks
-Shesh
------------------------------
Sheshnarayan Agrawal
------------------------------