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

Re: SQLSetPos problem ?

From: "lothar(dot)behrens(at)lollisoft(dot)de" <lothar(dot)behrens(at)lollisoft(dot)de>
To: pgsql-odbc(at)postgresql(dot)org
Subject: Re: SQLSetPos problem ?
Date: 2006-12-16 23:23:40
Message-ID: 1166311419.967140.317720@16g2000cwy.googlegroups.com (view raw or flat)
Thread:
Lists: pgsql-odbc
Hiroshi Inoue schrieb:

> lothar(dot)behrens(at)lollisoft(dot)de wrote:
> > Hiroshi Inoue schrieb:
> >
> >> lothar(dot)behrens(at)lollisoft(dot)de wrote:
> >>> Hiroshi Inoue schrieb:
> >>>
> >>>> lothar(dot)behrens(at)lollisoft(dot)de wrote:
> >>>>> Hi,
> >>>>>
> >>>>> I am using unixodbc in the latest version and psqlodbc 07.03.0200.
> >>>>> Having many queries working
> >>>>> good in my application one gives me this error, when updating a row.
> >>>> The version 7.3.0200 is pretty old.
> >>>> Please try the 8.2.xxxx version.
> >>>>
> >>> I need cursor functionality like first,back,next,last. Does the latest
> >>> driver support it ?
> >> Yes at least on Windows.
> >
> > Currently I have figured out, that my SQL_ADD statement fails
> > (SQLSetPos).
> > It seems, that I cannot insert new rows, because of foreign key
> > constraints.
> >
> > Removing the NOT NULL clauses of that columns didn't helped.
> >
> > With PGAdmin I was able to test inserting such a row. That worked.
> >
> > Any ideas ?
>
> How do you setting the foreign key column using PGadmin ?
>
> > If the bound columns having the wrong value - such as a non exsisting
> > foreign key -
> > how must it be filled to indicate a NULL value ?
> >
> > I bind such a column that way:
> >
> > buffer = malloc((ColumnSize+1)*rows);
> > memset(buffer, 0, (ColumnSize+1)*rows);
> > ret = SQLBindCol(hstmt, column, SQL_C_CHAR, buffer, (ColumnSize+1),
> > &cbBufferLength);
> >
> > Is that wrong ?
>
> I'm afraid I'm misunderstanding your point.
> Please set SQL_NULL_DATA to cbBufferLength to indicate the column is NULL.
> Also set SQL_COLUMN_IGNORE to cbBufferLength to ignore the column.
>

Hi,

I have added functions to set a column to be NULL and therefore, if I
add a new row,
my update function rebinds the relevant column as follows, before the
update:

cbBufferLength = SQL_NULL_DATA+SQL_COLUMN_IGNORE;
ret = SQLBindCol(hstmt, _column, DataType, buffer, 0, &cbBufferLength);

The information I got before this (SQLDescribeCol) returns Nullable = 1
and Datatype = 4.
So it should work.

But it haven't helped until I change the SQLSetPos line as follows:

from
		retcode = SQLSetPos(hstmt, 2, SQL_ADD, SQL_LOCK_NO_CHANGE);
to
		retcode = SQLSetPos(hstmt, 1, SQL_ADD, SQL_LOCK_NO_CHANGE);

It seems that I haven't correctly bound my columns. The second column
(2) came from
the documentation, that uses a special adding row. Thus, if I only have
one row for my data
to be shown, the second row was for adding.

But I only have provided one cbBufferSize variable, not an array of
two.

This was the cause, why my first try to only set SQL_NULL_DATA and
SQL_COLUMN_IGNORE
has been failed.

Is that correct ?

For the issue of adding a new row, the bug may be found.

One bug is remaining and it belongs to the same table and it may be
clear to me, what the cause
is.

But I am still wondering why my error handling code crashes :-(

Do you see any mistake ?

Here it is:

void lbQuery::dbError(char* lp, HSTMT hstmt)
{
	SQLCHAR  SqlState[6], SQLStmt[100], Msg[SQL_MAX_MESSAGE_LENGTH];
	SQLINTEGER NativeError;
	SQLSMALLINT i, MsgLen;
	SQLRETURN  rc;

	i = 1;

	while ((rc = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, i, SqlState,
&NativeError,
	      Msg, sizeof(Msg), &MsgLen)) != SQL_NO_DATA) {

		cout << "Error in lbQuery: (" << lp << ") " <<
			SqlState << ": " << (int) NativeError << " - " << Msg << endl;
		i++;
	}
}

Thanks, Lothar

> regards,
> Hiroshi Inoue
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>        message can get through to the mailing list cleanly


In response to

Responses

pgsql-odbc by date

Next:From: Hiroshi InoueDate: 2006-12-18 06:42:45
Subject: Re: Invalid byte sequence for encoding "UTF8": 0xa1 - when
Previous:From: Hiroshi InoueDate: 2006-12-15 04:02:26
Subject: Re: NaN values and ODBC/OLE

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