I've encounted a strange problem, When i use store procedure to insert a record, the string value expanded to the length of parameter length.
for example, I declared the procedure like this
the Database is MS SQLServer, the driver is JDBC-ODBC bridge)
<pre>
CREATE PROCEDURE [up_NewFwxxInfo]
@strBlockName varchar(100),
AS
insert into tbl1(BlockName) VALUES (@strBlockName)
</pre>
and i call the procedure like this:
CallableStatement stmt = conn.prepareCall("{ call up_NewFwxxInfo(?)};
stmt.setString("sky");
stmt.executeUpdate();
</pre>
Then execute a query and get result like this:
<pre>
select '-' + BlockName + "-" FROM Block WHERE BlockID=33
-sky -
</pre>
This show the string inserted expanded to the length of parameter @strBlockName. So I do a trick here:
<pre>
CREATE PROCEDURE [up_NewFwxxInfo]
@strBlockName varchar(100),
AS
select @strBlockName = RTrim(@strBlockName)
insert into tbl1(BlockName) VALUES (@strBlockName)
</pre>
This works, but can anyone give answer?