Trim Char fields

We are currently using Delphi with Borland database. We are planning to move from borland to Firebird libraries, (borland lib has mem leaks).

The problem that we are having now is, Firebird library returns a char with trailing spaces, which was somehow handled borland library. We have huge code written without any trimming.

So now if 'abc' is stored in char(10) field, it returns 'abc       '. and our code fails. I was wondering if there is some configuration that I can do on the DB or firebird library to automatically trim char fields.

Answers


  1. Why don't you just change fields types in a database from CHAR to VARCHAR?
  2. You can use TRIM() function in SELECT statement.
  3. You can put a couple of changes into IBX source codes in order to right trim CHAR strings.

This is per the requirements laid down in the SQL standards: CHAR fields should be returned padded with spaces to the maximum defined length. If you don't want that behaviour, you need to use VARCHAR instead of CHAR.

Update: Not sure if it is helpful, but according to this message you could create a workaround if you are using IBX.


Need Your Help

Count on RDD giving different results

scala cassandra apache-spark spark-cassandra-connector

I have a an RDD with more than 75 million rows and when I call count function on it, I get a different number everytime. My understanding was count is supposed to give the exact number.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.