[Microsoft][ODBC SQL Server Driver]String data, right trunca

General discussion forum about all databases other than SqlBase.
manimaran

[Microsoft][ODBC SQL Server Driver]String data, right trunca

Post by manimaran » 17 May 2011, 08:42

Hi,

When I execute the below query in my application getting the error "[Microsoft][ODBC SQL Server Driver]String data, right truncation".

"SELECT COUNT (*) FROM T016_port INTO :nCount WHERE portname = :spPortName"

In this query the "portname" column length in the db table is varchar(25)
spPortName is a parameter having the vaue more than 25 characters.
if the parameter value exceeds 25 chracters program display error msg.


Program through error only for SQL Server 2005. it's working fine with Oracle.
My application is developed in CTD 4.2

Thanks in advance

MANI

Jeff Luther

Re: [Microsoft][ODBC SQL Server Driver]String data, right trunca

Post by Jeff Luther » 17 May 2011, 21:12

Well, that error is coming from MS SS and indicates it doesn't like the value > 25 chars. If there's no error with Oracle, sounds like it's more forgiving.

Solution is to SalStrLeftX( spPortName, 25 )
to guarantee that you won't get the error. Though, that doesn't look good to me (though it is easy). The right thing to do is to make sure that wherever your spPortName is being assigned your code doesn't allow > 25 chars. in the first place. Alternatively, do an ALTER TABLE type statement and make the DB column portname larger.

There's no TD error here, if that's what you're reporting. It's a coding error to allow a spPortName value > 25 chars.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests