Title: Trailing spaces in fixed length non null character fields
Entry Number: Last Updated: 22 November 1995 Document Revision:
Keywords: space, Sybase, character, adaptor
Question
After installing EOF Release 1.1, I noticed that my column attributes which are defined as fixed length non-null character fields are now blank padded when fetched. How can I correct this behavior?
Answer
With the EOF 1.1 Sybase adaptor, non-null fixed length CHAR fields (for example CHAR(8)) end up space padded when fetched. This behavior is peculiar to Sybase, even though EOF Release 1.0 automatically removes these spaces.
You can return to the same behavior as in EOF 1.0 by adding the following code to your application. Note that you must statically link the Sybase adaptor with your application in order to use this workaround with the following Makefile.preamble option:
// You may freely copy, distribute, and reuse the code in this example.
// NeXT disclaims any warranty of any kind, expressed or implied, as to its
// fitness for any particular use.
//
// This code uses private API of the Sybase adaptor and will likely need
// to be changed for future releases of EOF.
//
// Below, we create a subclass of a private part of the Sybase adaptor
// (SybaseStringColumn) so that we can strip trailing blanks on columns
// declared "char not null". Char columns which can be null and varchar
// columns automatically have trailing spaces removed. If we were to let
// these extended values slip through to the database layer of EOF all kinds
// of problems would ensue because "hello" != "hello " in C, but they would
// be compared as equal in the db.