pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedStill SQLSetPos problem even with minimal sample, SQL_NULL_DATA and SQL_COLUMN_IGNORE ?
3+ messages / 2 participants
[nested] [flat]
* Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA and SQL_COLUMN_IGNORE ?
@ 2006-12-18 22:53 lothar.behrens@lollisoft.de <lothar.behrens@lollisoft.de>
0 siblings, 1 reply; 3+ messages in thread
From: lothar.behrens@lollisoft.de @ 2006-12-18 22:53 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA
@ 2006-12-18 23:40 Hiroshi Inoue <inoue@tpf.co.jp>
parent: lothar.behrens@lollisoft.de <lothar.behrens@lollisoft.de>
0 siblings, 1 reply; 3+ messages in thread
From: Hiroshi Inoue @ 2006-12-18 23:40 UTC (permalink / raw)
To: lothar.behrens@lollisoft.de <lothar.behrens@lollisoft.de>; +Cc: pgsql-odbc
lothar.behrens@lollisoft.de wrote:
> 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.
<snip>
> 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;
At first glance, adding SQL_NULL_DATA(=-1) and SQL_COLUMN_IGNORE(=-6)
seems to have no meaning.
If you really want to set to NULL on SQL_ADD, please set SQL_NULL_DATA.
If you want to set DEFAULT on SQL_ADD, please set SQL_COLUMN_IGNORE.
regards,
Hiroshi Inoue
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA
@ 2006-12-19 07:38 lothar.behrens@lollisoft.de <lothar.behrens@lollisoft.de>
parent: Hiroshi Inoue <inoue@tpf.co.jp>
0 siblings, 0 replies; 3+ messages in thread
From: lothar.behrens@lollisoft.de @ 2006-12-19 07:38 UTC (permalink / raw)
To: pgsql-odbc
Hiroshi Inoue schrieb:
> lothar.behrens@lollisoft.de wrote:
> > 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.
>
> <snip>
>
> > 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;
>
> At first glance, adding SQL_NULL_DATA(=-1) and SQL_COLUMN_IGNORE(=-6)
> seems to have no meaning.
> If you really want to set to NULL on SQL_ADD, please set SQL_NULL_DATA.
> If you want to set DEFAULT on SQL_ADD, please set SQL_COLUMN_IGNORE.
>
Ahh,
I misunderstood you. I will try that today.
regards,
Lothar
> regards,
> Hiroshi Inoue
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-12-19 07:38 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-12-18 22:53 Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA and SQL_COLUMN_IGNORE ? lothar.behrens@lollisoft.de <lothar.behrens@lollisoft.de>
2006-12-18 23:40 ` Re: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA Hiroshi Inoue <inoue@tpf.co.jp>
2006-12-19 07:38 ` Re: Still SQLSetPos problem even with minimal sample, SQL_NULL_DATA lothar.behrens@lollisoft.de <lothar.behrens@lollisoft.de>
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