Open firebird-automations opened 14 years ago
Commented by: Lester Caine (lsces)
http://www.firebirdsql.org/refdocs/langrefupd20-udf-lpad.html If endlength is less than str's length, str is truncated to endlength. If endlength is negative, the result is NULL. This is exactly the same as oracle, postgresql and mysql
Commented by: @livius2
if this is as designed then change description of this function because now is in README.builtin_functions.txt:
Function: LPAD(string1, length, string2) appends string2 to the beginning of string1 until length of the result string becomes equal to length.
Format: LPAD( <string>, <number> [, <string> ] )
Notes: 1) If the second string is omitted the default value is one space. 2) The second string is truncated when the result string will become larger than length.
Example: select lpad(x, 10) from y;
add in this description position: 3) If first string parameter is larger then number parameter then will be truncated
//############################################
and then i add new issue/new feature request to add some function like lpad and rpad without this limitation
Submitted by: @livius2
select LPAD('123', 4, '0') FROM RDB$DATABASE result '0123' ok
select LPAD('1234', 4, '0') FROM RDB$DATABASE result '1234' ok
select LPAD('12345', 4, '0') FROM RDB$DATABASE result is 1234 - this is wrong
result in this situation should be '12345'
lpad should not change string if length is longer then length parameter