I'm trying to update column of type uniqueidentifier with null. My query
looks like:
UPDATE table_name SET column_name = ?
The column is bound with:
SQLLEN _nullLen(SQL_NULL_DATA);
_rc = SQLBindParameter(_hstmt,
static_cast<SQLUSMALLINT>(1),
SQL_PARAM_INPUT,
SQL_C_CHAR,
SQL_VARCHAR,
37,
NULL,
NULL,
0,
&_nullLen);
Executing the query
results in a ODBC error 'String data, right truncation'.
Using the exact same SQLBindParameter
I'm able to successfuly insert a new row with null
data. Why does this not work for updating the row?
Please read
https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlbindparameter-function?view=sql-server-ver15 thoroughly.
According to it, the 6th parameter to SQLBindParameter is ColumnSize, which you set to 37. Why this value?
The 8th parameter is ParameterValuePtr, but you set it to NULL. Is NULL the value you are trying to set?
The 10th parameter is StrLen_or_IndPtr which you set to &_nullLen
where SQLLEN _nullLen(SQL_NULL_DATA)
, but that's not the kind of thing it should point to.
Please make sure you understand each parameter passed to SQLBindParameter()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With