Subject | padding results from case expression |
---|---|
Author | knisco99 |
Post date | 2007-04-18T19:51:08Z |
Recently while working with a new stored procedure in Firebird 1.5.3
on linux a developer tried out using a case expression. Our java
developer then noticed that the result was being padded with spaces
according to the largest string in the case statement. You can see
this same behaviour in a select query
select strlen( case when 1=1 then 'test' when 2=0 then 'biggertest'
else 'control' end )
from rdb$database
If you remove the strlen it is returning test but the length returned
is 10 the size of the biggertest string. This confirms what java was
getting which was a result of 'test '
Is this supposed to be the behavior of a case statement? Am I not
understanding something?
Thanks,
Scott Knight
on linux a developer tried out using a case expression. Our java
developer then noticed that the result was being padded with spaces
according to the largest string in the case statement. You can see
this same behaviour in a select query
select strlen( case when 1=1 then 'test' when 2=0 then 'biggertest'
else 'control' end )
from rdb$database
If you remove the strlen it is returning test but the length returned
is 10 the size of the biggertest string. This confirms what java was
getting which was a result of 'test '
Is this supposed to be the behavior of a case statement? Am I not
understanding something?
Thanks,
Scott Knight