pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: lothar.behrens@lollisoft.de <lothar.behrens@lollisoft.de>
To: pgsql-odbc@postgresql.org
Subject: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA and SQL_COLUMN_IGNORE ?
Date: 18 Dec 2006 14:53:44 -0800
Message-ID: <1166482424.555811.255330@j72g2000cwa.googlegroups.com> (raw)
In-Reply-To: <1166311419.967140.317720@16g2000cwy.googlegroups.com>
References: <1165751917.708138.93120@j72g2000cwa.googlegroups.com>
	<457CACE1.2090907@tpf.co.jp>
	<1165848049.639913.7360@n67g2000cwd.googlegroups.com>
	<457DF1D9.7080804@tpf.co.jp>
	<1165955153.386694.185060@f1g2000cwa.googlegroups.com>
	<457F4E43.108@tpf.co.jp>
	<1166311419.967140.317720@16g2000cwy.googlegroups.com>

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




view thread (3+ messages)  latest in thread

Message-ID: <1166482424.555811.255330@j72g2000cwa.googlegroups.com>
Permalink:  ../1166482424.555811.255330@j72g2000cwa.googlegroups.com/
Also on:    postgresql.org/message-id/1166482424.555811.255330@j72g2000cwa.googlegroups.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: lothar.behrens@lollisoft.de
  Subject: Re: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA and SQL_COLUMN_IGNORE ?
  In-Reply-To: <1166482424.555811.255330@j72g2000cwa.googlegroups.com>
  References: <1165751917.708138.93120@j72g2000cwa.googlegroups.com> <457CACE1.2090907@tpf.co.jp> <1165848049.639913.7360@n67g2000cwd.googlegroups.com> <457DF1D9.7080804@tpf.co.jp> <1165955153.386694.185060@f1g2000cwa.googlegroups.com> <457F4E43.108@tpf.co.jp> <1166311419.967140.317720@16g2000cwy.googlegroups.com> <1166482424.555811.255330@j72g2000cwa.googlegroups.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox