Re: Sqlnotfound in non ansi compliant Database ??
Posted in 1999
Thorsten Geelhaar wrote: > > Hello , > > Can anyone tell me how i examine if a statement delivers no rows in a > non > ansi compliant database (7.30C8 dynamic online). > As i no the sqlcode is set to 0 if nothing is found with the exception > of a select statement. Then it is set to 100. Correct. > But on any other statement is set to 0 also,if there go nothing wrong > respectivly the syntax of the statement was correct. Correct, ie an update that updates zero rows is NOT an error, nor is a delete that effects no rows. For these statements check the sqlca structure field sqlca.sqlerrd[2] contains the number of rows affected by the last SQL command if it is an UPDATE or DELETE. > I must know a way to check it for fetch statement with an without > cursor. Well a FETCH is ONLY used with a CURSOR and returns the same result as a SELECT statement (ie zero if successful and SQLNOTFOUND if no rows found). A stand alone SELECT, however, without a CURSOR, cannot return more than one row so the count is known in advance. If you have not used dynamic SQL techniques to enable array fetching and return multiple rows in a single FETCH the FETCH will either return one row or the sqlca.sqlcode will be 100 (SQLNOTFOUND) after the call following that which returned the last available row. If array fetching IS enabled then the sqlca structure will report how many rows were loaded into the data column arrays just as it report for UPDATE and DELETE statements through the field sqlda.sqlerrd[2]. There is lots of excellent example code in the ESQL/C manual and samples directory on your development site. In addition take a look at the source for such excellent examples of well written ESQL/C as Jonathan Leffler's sqlcmd program or my utilities in the package utils2_ak in the IIUG Software Repository. :-) Art S. Kagel