开发者

Remove padding added by legacy DB2 databases on query results

I have the following setup.

'Apps/Reports' <---------> 'DB2 Connect' <------------> 'Legacy DB2 on AS400'
               `Hibernate`               `native calls`

When data is retrieved开发者_Python百科 from by the application, it will be padded with extra spaces if the length is less that the column length. Of note when running a query, if the WHERE cause parameter is not padded, its automatically padded with extra spaces such that the query will retrieve the same records for a padded and non-padded parameter.

Is there a way (preferably on IBM DB2 Connect or connection string parameter) to remove extra whitespaces from a resultset?


You could implement an hibernate UserType that automatically trim the strings. There are good exmaples on

https://forum.hibernate.org/viewtopic.php?t=928294

http://java.dzone.com/articles/annotating-custom-types

http://santescas.blogspot.de/2014/02/creando-un-usertype-de-hibernate-que-se.html


Are the columns in the iSeries defined as CHAR()? I'm assuming so, because this is how CHAR() works -- it's a fixed field length, not a variable field length (that's what VARCHAR is for).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜