SAP/odbc-cpp-wrapper

Error HY104 on Parameter of Type cString

Closed this issue · 4 comments

I am trying to get your wrapper to work with MS SQL Server 2014.
To test it, i already created a TAB table with two Fiels.
ID = int
DATA = varchar(50)

But on this Statement, i get the errorcode posted in the description.

odbc::PreparedStatementRef psInsert =
conn->prepareStatement ("INSERT INTO TAB (ID, DATA) VALUES (?, ?)");
psInsert->setInt (1, 101);
psInsert->setCString (2, "One hundred one");
psInsert->executeQuery ();

You set the ColumnSize parameter of "SQLBindParameter" from the Member "columnSize_"
But this is always 0, because ParameterData::setValue sets always 0.

So would this be a bug?
Or just a problem with older versions?

Because i just cant wrap my head around the documentation of SQLBindParameter:
https://docs.microsoft.com/de-de/sql/odbc/reference/syntax/sqlbindparameter-function?view=sql-server-ver15

I could reproduce the issue (you should call executeUpdate() instead of executeQuery(), but that does not solve the problem).

It seems the Microsoft driver is not happy with the column size being 0. When the column size is set to the length of the string, the query works.

I have to study the documentation of SQLBindParameter() again and have to verify that the fix does not introduce any regressions. This could take some time.

Any update?

Sorry for the delay. I'm working on it right now.

I managed to fix it. I can do a pull request if you want.