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.
- Why don't you just change fields types in a database from CHAR to VARCHAR?
- You can use TRIM() function in SELECT statement.
- 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.