FirebirdSQL logo

RIGHT()

Extracts the rightmost part of a string

Result type

VARCHAR or BLOB

Syntax
RIGHT (string, length)
Table 1. RIGHT Function Parameters
Parameter Description

string

An expression of a string type

length

Integer.The number of characters to return

  • This function supports text BLOBs of any length.

  • If string is a BLOB, the result is a BLOB.Otherwise, the result is a VARCHAR(n) with n the length of the input string.

  • If the length argument exceeds the string length, the input string is returned unchanged.

  • If the length argument is not a whole number, bankers' rounding (round-to-even) is applied, i.e. 0.5 becomes 0, 1.5 becomes 2, 2.5 becomes 2, 3.5 becomes 4, etc.

Warning

When used on a BLOB, this function may need to load the entire object into memory.This may affect performance if huge BLOBs are involved.

RPAD()

Right-pads a string

Result type

VARCHAR or BLOB

Syntax
RPAD (str, endlen [, padstr])
Table 1. RPAD Function Parameters
Parameter Description

str

An expression of a string type

endlen

Output string length

endlen

The character or string to be used to pad the source string up to the specified length.Default is space (' ')

Right-pads a string with spaces or with a user-supplied string until a given length is reached.

  • This function fully supports text BLOBs of any length and character set.

  • If str is a BLOB, the result is a BLOB.Otherwise, the result is a VARCHAR(endlen).

  • If padstr is given and equals '' (empty string), no padding takes place.

  • If endlen is less than the current string length, the string is truncated to endlen, even if padstr is the empty string.

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.