Thread: Delete row (SQLSetPos) and then fetch over ?

Delete row (SQLSetPos) and then fetch over ?

From
lothar.behrens@lollisoft.de
Date:
Hi,

I am struggling with deleting a row in my cursor. The scenaio is as following:

I add some rows with empty data, some default columns and the like. Then I check
the contents by using the application to scroll over row by row. This works fine.

Deleting the second last row let the GUI afterwards show the last row. Looks ok as
expected. But after going one row back (the deleted row), my application shows
rubbish and may crash afterwards.

How looks like correct ODBC code to detect the 'navigation' to the 'deleted' row ?

Thanks, Lothar

My code looks like this:

lbErrCodes LB_STDCALL lbQuery::previous() {
        UWORD   RowStat[20];
        UDWORD  RowsFetched = 0;

        retcode = SQLExtendedFetch(    hstmt,
                    SQL_FETCH_PREV,
                    0, &RowsFetched, RowStat);

        if (retcode == SQL_NO_DATA) {
    // Go back to valid row
    retcode = SQLExtendedFetch(hstmt,
                    SQL_FETCH_NEXT,
                    0, &RowsFetched, RowStat);
    return ERR_DB_NODATA;
        } else {
    // Peek one row to detect if further scroll previous would be possible
    retcode =
    SQLExtendedFetch(hstmt, SQL_FETCH_PREV, 0, &RowsFetched,
RowStat);
    if (retcode == SQL_NO_DATA) {
          SQLExtendedFetch(hstmt,
            SQL_FETCH_NEXT, 0, &RowsFetched, RowStat);
        return WARN_DB_NODATA;
    } else {
          SQLExtendedFetch(hstmt,
            SQL_FETCH_NEXT, 0, &RowsFetched, RowStat);
        return ERR_NONE;
    }
        }

--
Lothar Behrens    |    Rapid Prototyping ...
Rosmarinstr 3        |
40235 Düsseldorf      |    www.lollisoft.de