RE: [bug-report]SQLRowCount set affected row numbers is incorrect when use SQLBindParameter and SQLSetStmtAttr for SQL_ATTR_PARAMSET_SIZE

From: "Wal, Jan Tjalling van der" <jan_tjalling(dot)vanderwal(at)wur(dot)nl>
To: Chang Lu <luchang0624(at)gmail(dot)com>, "pgsql-odbc(at)lists(dot)postgresql(dot)org" <pgsql-odbc(at)lists(dot)postgresql(dot)org>
Subject: RE: [bug-report]SQLRowCount set affected row numbers is incorrect when use SQLBindParameter and SQLSetStmtAttr for SQL_ATTR_PARAMSET_SIZE
Date: 2024-07-18 10:30:14
Message-ID: AM0PR01MB5634C60C9672C6F71C56C110DDAC2@AM0PR01MB5634.eurprd01.prod.exchangelabs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hi Chang Lu,

I guess the behaviour is correct and as expected.

It seems that each of your updates affects one record.
And you receive back that correct count as number_affected for that (single) statement as just one.

To keep track of how many records have been successfully updated by the script/procedure, you probably need to add a step to sum the number_affected to get your final number of updated records.
It might worthwhile to log single values of number_affected that report back as zero.

Kind regards, Jan Tjalling van der Wal
Wageningen Marine Reseach (WMR) / formerly IMARES Institute for Marine Resources & Ecosystem Studies
Ankerpark 27, 1781 AG Den Helder Postbus 57, 1780 AB Den Helder
Tel. +31 (0)317-4 87147 # GSM. +31 (0)626120915 (privé) #
# Ma+Di Vr 09:00-18:00, Wo XX, Do+Vr 09:00-18:00
Jan_Tjalling(dot)vanderWal(at)wur(dot)nl<mailto:Jan_Tjalling(dot)vanderWal(at)wur(dot)nl>
From: Chang Lu <luchang0624(at)gmail(dot)com>
Sent: Thursday, 18 July 2024 11:54
To: pgsql-odbc(at)lists(dot)postgresql(dot)org
Subject: [bug-report]SQLRowCount set affected row numbers is incorrect when use SQLBindParameter and SQLSetStmtAttr for SQL_ATTR_PARAMSET_SIZE

Hi,

I'm tring to insert and update a lot of records using SQLBindParameter and SQLSetStmtAttr, but SQLRowsCount returned record number affected by ONLY the LAST SINGLE SQL STATEMENT.

Here is my code sequence.

1.
status = SQLBindParameter(cda,
KCPD_SCAST(KCPD_SQLUSMALLINT, parm_pos),
KCPD_SCAST(KCPD_SQLSMALLINT, param_type),
ftype,
KCPD_SCAST(KCPD_SQLSMALLINT, mapped_sqltype),
temp_column_size,
sqltype == SQL_TYPE_TIMESTAMP ? kcpd_odbc_date_scale : 0,
KCPD_RCAST(KCPD_SQLPOINTER, v.p_v),
buflen,
v.p_len);

2.
status = SQLSetStmtAttr(cda,
SQL_ATTR_PARAMSET_SIZE,
KCPD_RCAST(void*, temp_iters),
SQL_NTS);

3.
status = SQLExecute(cda);

4.
SQLRowCount(cda, affected_num);

I inserted 1000 records into the table, but affected_num set by SQLRowCount is 1

I searched the source code for this issue, and found in CC_send_query_append (connection.c:2062)
[cid:image001(dot)png(at)01DAD90D(dot)72A9BDE0]
My question is :
Is this line (connection.cpp : 2062) has a bug? I think it may use '+=' rather than '='.
lack of libpg.dll and headers, I cannot compile the source code and check my idea.

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Rodrigo Garzón 2024-07-18 14:00:58 Re: PLASE HELP- Error ANSI 13 in ARM Windows 11
Previous Message Dave Cramer 2024-07-18 10:02:32 Re: [bug-report]SQLRowCount set affected row numbers is incorrect when use SQLBindParameter and SQLSetStmtAttr for SQL_ATTR_PARAMSET_SIZE