RPAD()
<< ROUND() | FB 2.1 Language Reference | SIGN() >> 
RPAD()
Added in: 2.1
Description
Right-pads a string with spaces or with a user-supplied string until a given length is reached.
Result type: VARCHAR(32765) or BLOB
Syntax
RPAD (str, endlen [, padstr])
- This function fully supports text BLOBs of any length and character set.
- If stris a BLOB, the result is aBLOB. Otherwise, the result is aVARCHAR(32765).
- If padstris given and equals''(empty string), no padding takes place.
- If endlenis less than the current string length, the string is truncated toendlen, even ifpadstris the empty string.
Important: If the external function RPAD is declared in your database, it will override the internal function. To make the internal function available, DROP or ALTER the external function (UDF).
Tip: With (VAR)CHARs, it is generally wise to CAST the result to a smaller size. The default result length of 32765 may, in combination with other output columns, lead to a block size exceeds implementation restriction error.
Examples
 rpad ('Hello', 12)                   -- returns 'Hello '
 rpad ('Hello', 12, ')                   -- returns 'Hello------
 rpad ('Hello', 12, '')               -- returns 'Hello'
 rpad ('Hello', 12, 'abc')            -- returns 'Helloabcabca'
 rpad ('Hello', 12, 'abcdefghij')     -- returns 'Helloabcdefg'
 rpad ('Hello', 2)                    -- returns 'He'
 rpad ('Hello', 2, '-')               -- returns 'He'
 rpad ('Hello', 2, '')                -- returns 'He'
Warning: When used on a BLOB, this function may need to load the entire object into memory. Although it does try to limit memory consumption, this may affect performance if huge BLOBs are involved.
See also:
LPAD()
back to top of page 
<< ROUND() | FB 2.1 Language Reference | SIGN() >> 








