Problem with ESQL/C 7.20
Posted in 1997
Hello out there, I've written a short ESQL-program which shows me the datatype of a aggregate function in a SELECT statement. This program is working well with a INFORMIX5 db as backend, but if I access a INFORMIX7 db I get an incorrect datatype. But it is important for me to get the correct datatype. I've included the source: #include <stdio.h> $include sqlca.h; $include sqltypes.h; #include <login.h> #include <datetime.h> #include <value.h> #include <sqlproto.h> int main() { EXEC SQL BEGIN DECLARE SECTION; long int anzahl; int desc_count, i, type; EXEC SQL END DECLARE SECTION; sprintf(InetLogin.Host, "host"); sprintf(InetLogin.User, "informix"); sprintf(InetLogin.Pass, "xxxxxxxx"); EXEC SQL DATABASE "testdb"; if(sqlca.sqlcode < 0) { printf("SQLCODE = %ld\\n", sqlca.sqlcode); return(0); } EXEC SQL PREPARE prep FROM "select count(*) from test"; EXEC SQL DECLARE cursor CURSOR FOR prep; EXEC SQL ALLOCATE DESCRIPTOR 'desc' WITH MAX 1; EXEC SQL OPEN cursor; EXEC SQL DESCRIBE prep USING SQL DESCRIPTOR 'desc'; EXEC SQL GET DESCRIPTOR 'desc' :desc_count = COUNT; for(i = 1; i <= desc_count; i++) { EXEC SQL GET DESCRIPTOR 'desc' VALUE: i :type = TYPE; printf("Type = %d\\n", type); } for(;;) { EXEC SQL FETCH cursor INTO :anzahl; if(sqlca.sqlcode == 100) break; printf("# of rows: %ld\\n", anzahl); } EXEC SQL CLOSE DATABASE; return 0; } With a INFORMIX5 backend I'll get the correct values: Type = 2 (ID for an integer field) # of rows = 26 With a INFORMIX7 backend I'll get incorrect values: Type = 5 (ID for a decimal field) # of rows = 0 My configuration: WIN95 INFORMIX ESQL/C 7.20.TE1 MSVC 4.2 Does anybody have a conclusion for this behaviour. Any hints are appreciated! Thanks in advance Dirk email : dirk.scheer@stadt-mh.de