Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateExternal functions (UDFs) → rpad
Firebird Home Firebird Home Prev: round, i64roundFirebird Documentation IndexUp: External functions (UDFs)Next: rtrim

rpad

Library: ib_udf

Added in: 1.5

Changed in: 1.5.2, 2.0

Better alternative: Internal function RPAD()

Description: Returns the input string right-padded with padchars until endlength is reached.

Result type: VARCHAR(n)

Syntax: 

rpad (str, endlength, padchar)

Declaration: 

DECLARE EXTERNAL FUNCTION rpad
   CSTRING(255) NULL, INTEGER, CSTRING(1) NULL
   RETURNS CSTRING(255) FREE_IT
   ENTRY_POINT 'IB_UDF_rpad' MODULE_NAME 'ib_udf'

The above declaration is from the file ib_udf2.sql. The NULLs after the CSTRING arguments are an optional addition that became available in Firebird 2. If an argument is declared with the NULL keyword, the engine will pass a NULL argument value unchanged to the function. This leads to a NULL result, which is correct. Without the NULL keyword (your only option in pre-2.0 versions), NULLs are passed to the function as empty strings and the result is a string with endlengh padchars (if str is NULL) or a copy of str itself (if padchar is NULL).

For more information about passing NULLs to UDFs, see the note at the end of this book.

Notes: 

Prev: round, i64roundFirebird Documentation IndexUp: External functions (UDFs)Next: rtrim
Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateExternal functions (UDFs) → rpad