Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA and SQL_COLUMN_IGNORE ?

Поиск
Список
Период
Сортировка
От lothar.behrens@lollisoft.de
Тема Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA and SQL_COLUMN_IGNORE ?
Дата
Msg-id 1166482424.555811.255330@j72g2000cwa.googlegroups.com
обсуждение исходный текст
Ответ на Re: SQLSetPos problem ?  ("lothar.behrens@lollisoft.de" <lothar.behrens@lollisoft.de>)
Ответы Re: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA
Список pgsql-odbc
Hi,

I have implemented setting SQL_COLUMN_IGNORE, SQL_NULL_DATA and have
added functions
to indicate this state.

I have made a 'small' sample application to demonstrate this, but I
still use my ODBC wrapper
classes in that sample application. You may get access to the full
code. Ask for it!

The first insert is with valid foreign keys and no column set to NULL.
This insert works.
My next insert has set the columns to NULL, but it inserts the values
of the last insert.

SetNull("column XYZ"); does not work, even I check before and after the
update command,
that the columns are still set to NULL. This is as expected.

If I set illegal foreign keys and also have set NULL column, I get the
following error:

lbDB.cpp, 3417: Error in lbQuery: (SQLSetPos()) HY000: 7 -
[unixODBC]Error while executing the query;
FEHLER:  Einf�gen oder Aktualisieren in Tabelle �user_anwendungen�
verletzt Fremdschl�ssel-Constraint
�cst_user_anwendungen_anwendungenid�

Currently I have made an array of long (cbBufferLength[2]) and set this
explicitely short before
the call to SQLSetPos:

    if (mode == 1) // 1 means adding
        cbBufferLength[1] = SQL_NULL_DATA+SQL_COLUMN_IGNORE;
    else
        cbBufferLength[0] = SQL_NULL_DATA+SQL_COLUMN_IGNORE;

    SQLRETURN ret;

    ret = SQLDescribeCol( hstmt, _column, ColumnName,
                                    BufferLength, &NameLength, &DataType,
                                    &ColumnSize, &DecimalDigits,
&Nullable);

    _isNullable = Nullable == 1;

    if (ret != SQL_SUCCESS) {
        printf("Error: Failed to get column description for column %d.\n",
_column);
        query->dbError("SQLDescribeCol()", hstmt);
    }

    ret = SQLBindCol(hstmt, _column, DataType, buffer, 0, cbBufferLength);

// ...

lbErrCodes LB_STDCALL lbQuery::update() {
    lbErrCodes err = ERR_NONE;

    if (boundColumns != NULL) {
        boundColumns->indicateNullValues(); // calls the above code per NULL
column.
        boundColumns->unbindReadonlyColumns(); // Unbinds readonly columns

        if ((mode == 1) && (!boundColumns->hasValidData())) { // either set
valid with setNull() or setString("...") per column.
            _CL_LOG << "Error: Query has not got valid data to be added." LOG_
            mode = 0;
            return ERR_DB_UPDATEFAILED;
        }
    }

    if (mode == 1) {

        retcode = SQLSetPos(hstmt, 2, SQL_ADD, SQL_LOCK_NO_CHANGE);

        if (retcode != SQL_SUCCESS)
        {
                dbError("SQLSetPos()", hstmt);
                _LOG << "lbQuery::update(...) adding failed." LOG_

// ...

The functions are definitely called and cbBufferLength[1] is set to -7
(SQL_NULL_DATA+SQL_COLUMN_IGNORE)

I have no idea what could be wrong. :-(

Hope to get a light :-)

Thanks, Lothar


В списке pgsql-odbc по дате отправления:

Предыдущее
От: "Michael Kochetkov"
Дата:
Сообщение: Query batches and SQLMoreResults
Следующее
От: Hiroshi Inoue
Дата:
Сообщение: Re: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA