Subject Re: [firebird-support] Autotrim?
Author Mark Rotteveel
On Fri, 02 Mar 2012 09:03:02 +0100, Mark Rotteveel <mark@...>
wrote:
> On Tue, 28 Feb 2012 07:37:59 -0000, "syn.erpy" <syn.erpy@...>
wrote:
>> Hi,
>>
>> we ran into a little problem regarding blanks.
>>
>> Try the following code (FB 2.5.1):
>>
>> <code>
>> create exception blank 'blank';
>>
>> SET TERM ^ ;
>>
>> create OR alter procedure p_test
>> as
>> begin
>>
>> IF (' ' = '') THEN
>> exception blank;
>> end
>> ^
>>
>> SET TERM ; ^
>>
>> execute procedure p_test;
>>
>>
>> </code>
>>
>> If you run it, the exception is raised. My question is why Firebird
> thinks
>> that a blank (or two or three or four for that matter) is the same as
an
>> empty string. Is this a bug or an intended feature?
>
> Because that is what the SQL standard defines: When comparing strings
the
> shorter string is padded with spaces to the length of the longer string,
> and then they are compared. So if two strings have the same prefix and
the
> rest is a (different) number of spaces, then they are still considered
the
> same.

I am not 100% sure (and no Firebird installation at hand to check), but I
believe ' ' IS DISTINCT FROM '' should work.

Mark