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

From: "lothar(dot)behrens(at)lollisoft(dot)de" <lothar(dot)behrens(at)lollisoft(dot)de>
To: pgsql-odbc(at)postgresql(dot)org
Subject: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA and SQL_COLUMN_IGNORE ?
Date: 2006-12-18 22:53:44
Message-ID: 1166482424.555811.255330@j72g2000cwa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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: Einfgen oder Aktualisieren in Tabelle user_anwendungen
verletzt Fremdschlssel-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

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Hiroshi Inoue 2006-12-18 23:40:30 Re: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA
Previous Message Michael Kochetkov 2006-12-18 19:00:38 Query batches and SQLMoreResults