Re: ESQL/C bug?
Posted in 1997
}[...] when the FETCH gets to the end of the }cursor SQLCODE gets 100 (That is right) but errno gets 2 (why??) } }I looked at the errno = 2 and is related to file not found. errno can be set by any of a multitude of routines, and none of them ever reset it to zero. The only time that you should inspect errno is after a routine has returned an error indication that means that errno is significant. ESQL/C does not document any circumstances under which it sets errno -- therefore, it is never valid to check it after an SQL statement has failed. I'm afraid that you're code is making unwarranted assumptions about errno, and is finding that those assumptions are now unjustified. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> PS: See Plauger 'The Standard C Library' for a description of errno. PPS: I note that the "EXEC SQL CODE C1;" doesn't compile, so you haven't sent us an exact copy of your working code... }From: ccremid@saadev.saa.noaa.gov }Date: 27 Mar 1997 19:46:18 GMT }X-Informix-List-Id: <news.35943> } }We are migrating from ESQL/C v5.00 to ESQL/C V 7.21 and we found }that the following code produces undesirable results. Has anyone }came across with the same?. Is this a bug? } }Just to be complete: AIX 4.2 and Informix Online 7.21 } }#include errno.h }int main (int argc, char **argv) { } } EXEC SQL BEGIN DECLARE SECTION; } char code[3]; } EXEC SQL END DECLARE SECTION; } } EXEC SQL DATABASE stores7; } EXEC SQL DECLARE C1 CURSOR FOR SELECT code from state; } EXEC SQL OPEN C1; } } for (;;) { } } EXEC SQL FETCH c1 INTO :code; } printf("ERROR: %d SQL %d \\n",errno,SQLCODE); } if (SQLCODE != 0) break; } } printf("%s\\n",code); } } } } } EXEC SQL CODE C1; } exit(0); } }} } }Well what happens is that when the FETCH gets to the end of the }cursor SQLCODE gets 100 (That is right) but errno gets 2 (why??) } }I looked at the errno = 2 and is related to file not found. } }We are using generic error logging functions that works with the }errno variable and this behaviour (bug??) is causing multiple }problems. } }I run the same code in AIX 3.2.5 and ESQL/C V 5.00 and errno is }always zero } }Yes, I know that I can set errno to zero after an SQLCODE = 100 is }is found, but we are talking about many programs. } }If someone has a better solution please e-mail me }ccremid@saadev.saa.noaa.gov } }Thanks in advance } }Tino } }-- } }Posted using Reference.COM http://www.reference.com }Browse, Search and Post Usenet and Mailing list Archive and Catalog. } }InReference, Inc. accepts no responsibility for the content of this posting. }