credativ / informix_fdw

Foreign Data Wrapper for Informix Databases
Other
28 stars 5 forks source link

Float problem (question) #6

Closed Sett closed 9 years ago

Sett commented 9 years ago

Hi. There is a strange problem when i'am trying to view rows of a table, which contains float fields: error happens: "'3' is not a known informix type id" I looked through sources (FDW and Informix) and float is defined (float id=3). Can you promt me, what can be the source of the problem?

psoo commented 9 years ago

Unfortunately, FLOAT is indeed not supported by the Informix FDW yet. I admit the error message is a little bit misleading, i'm going to look wether i can make it more verbose.

However, you can just use a cast to select those values. You need to use the 'query' attribute for foreign tables instead of 'table', though. Here's an example. Say you have this table in Informix:

CREATE TABLE float_test(val float);
INSERT INTO float_test VALUES(6.33333333333);
INSERT INTO float_test VALUES(1.2345);

To use that value someone can use the following foreign table definition:

CREATE FOREIGN TABLE float_test(val numeric)
SERVER centosifx
OPTIONS(db_locale 'en_US.819',
                 client_locale 'en_US.819',
                 database 'regression_dml',
                 informixdir '/opt/IBM/informix',
                 query 'SELECT CAST(val AS numeric) FROM float_test');

Note the 'query' option to the foreign table with the numeric cast. That gives:

SELECT * FROM float_test ;
      val      
---------------
        1.2345
 6.33333333333
(2 rows)

Maybe this workaround works for you.

I'm planning to complete all the datatypes for Informix FDW, but my current free time didn't permit to tackle it recently :/

Sett commented 9 years ago

Thanks, this workaround is nicely works for me.

psoo commented 9 years ago

FYI, i've committed support for FLOAT/REAL datatype support, see commit 951268d7b08f7e6edf1e2340088657b5fdca7912.

Sett commented 8 years ago

Great job! Thanx!