Page 1 of 1

SUBSTRING() returns too many characters

Posted: Fri Dec 17, 2010 7:29 pm
by bs27975
Spreadsheet basis.

SUBSTRING(str,pos,len) returns too many characters when len > length(str), rather than stopping at the end of the string, as would be usual in most other implementations. (Albeit, for all I know, perhaps not in SQL.) In my discovery, chinese characters are returned.

If str is 20 characters then SUBSTRING(<field>,4,16) does the expected.

if str is less, it keeps going ... somewhere.

Sadly, I couldn't do SUBSTRING(<field>,4,MAX(LENGTH(<field>,16))). And no IF in file functions either.

Bummer.

Re: BUG: SUBSTRING() returns too many characters.

Posted: Fri Dec 17, 2010 7:41 pm
by FJCC
I don't see this behavior when querying a table in an embedded database. Do you see Embedded Database at the lower left of your Base document. What type of field are you working with, a VARCHAR or something else?

Re: BUG: SUBSTRING() returns too many characters.

Posted: Fri Dec 17, 2010 8:26 pm
by r4zoli
If str is 20 characters then SUBSTRING(<field>,4,16) does the expected.

if str is less, it keeps going ... somewhere.
It works for me in OOo 3.3RC8 with fields containing even a 3 character long string.