Skip site navigation (1) Skip section navigation (2)

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: (view raw or whole thread)
Lists: pgsql-odbc

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

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


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

	_isNullable = Nullable == 1;

	if (ret != SQL_SUCCESS) {
		printf("Error: Failed to get column description for column %d.\n",
		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
		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;

	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

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

Hope to get a light :-)

Thanks, Lothar

In response to


pgsql-odbc by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group