-
August 1st, 2017, 11:45 AM
#1
Query fails with C++ ODBC - works with Management Studio
Hi, ALL,
I'm trying to execute a following query (using MSBV 2010, ODBC, SQL Server 2008):
Code:
L"SELECT rtrim(abt_tnam), abt_tid, rtrim(abt_ownr), abd_fhgt, abd_fwgt, abd_fitl, abd_funl, abd_fchr, abd_fptc, rtrim(abd_ffce), abh_fhgt, abh_fwgt, abh_fitl, abh_funl, abh_fchr, abh_fptc, rtrim(abh_ffce), abl_fhgt, abl_fwgt, abl_fitl, abl_funl, abl_fchr, abl_fptc, rtrim(abl_ffce), rtrim(abt_cmnt) FROM abcattbl WHERE \"abt_tnam\" = ? AND \"abt_ownr\" = ?;";
When executed inside SQL Server Management Studio there is no issue. The query is executing fine and I am getting the results.
However when executing thru the C++ code, the call to SQLExecute() fails. The error is:
String data, right truncation
and the error code is 22001.
If I Remove rtrim() calls, everything works fine. Unfortunately this is not an option as those fields are char() and not varchar().
Moreover this same query works fine on PostgreSQL driver on OSX with iODBC DM.
Trying to wrap the parameters with rtrim() also doesn't help. I'm getting exactly the same error.
Below is the table structure:
Code:
CREATE TABLE \"abcattbl\"(abt_tnam char(129) NOT NULL, abt_tid integer, abt_ownr char(129) NOT NULL, abd_fhgt smallint, abd_fwgt smallint, abd_fitl char(1), abd_funl char(1), abd_fchr smallint, abd_fptc smallint, abd_ffce char(18), abh_fhgt smallint, abh_fwgt smallint, abh_fitl char(1), abh_funl char(1), abh_fchr smallint, abh_fptc smallint, abh_ffce char(18), abl_fhgt smallint, abl_fwgt smallint, abl_fitl char(1), abl_funl char(1), abl_fchr smallint, abl_fptc smallint, abl_ffce char(18), abt_cmnt char(254) PRIMARY KEY( abt_tnam, abt_ownr ));
Does anybody have an idea what is going on and how do I fix this?
TIA!
-
August 1st, 2017, 12:24 PM
#2
Re: Query fails with C++ ODBC - works with Management Studio
Did you search the google for this error?
Could this help?
Victor Nijegorodov
-
August 1st, 2017, 03:23 PM
#3
Re: Query fails with C++ ODBC - works with Management Studio
Hi, VictorN,
Originally Posted by VictorN
Did you search the google for this error?
Could this help?
Yes, I did search, but didn't see that link.
I will try to call the function referenced and hopefully it will be fixed.
Thx.
-
August 1st, 2017, 09:45 PM
#4
Re: Query fails with C++ ODBC - works with Management Studio
VictorN,
Adding the function from the link you referenced solved it.
Thx.
P.S.: Sorry, I didn't get this in my google search.
-
August 2nd, 2017, 12:32 AM
#5
Re: Query fails with C++ ODBC - works with Management Studio
You are welcome!
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|