21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Added in: <strong>2.1</strong><br />

Internal functions<br />

Description: Right-pads a string with spaces or with a user-supplied string until a given length is reached.<br />

Result type: VARCHAR(32765) or BLOB<br />

Syntax:<br />

Examples:<br />

RPAD (str, endlen [, padstr])<br />

• This function fully supports text BLOBs of any length and character set.<br />

• If str is a BLOB, the result is a BLOB. Otherwise, the result is a VARCHAR(32765).<br />

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

• If endlen is less than the current string length, the string is truncated to endlen, even if padstr<br />

is the empty string.<br />

Important<br />

If the external function RPAD is declared in your database, it will override the internal function. To make the<br />

internal function available, DROP or ALTER the external function (UDF).<br />

Tip<br />

With (VAR)CHARs, it is generally wise to CAST the result to a smaller size. The default result length of 32765<br />

may, in combination with other output columns, lead to a “block size exceeds implementation restriction” error.<br />

rpad ('Hello', 12) -- returns 'Hello '<br />

rpad ('Hello', 12, '-') -- returns 'Hello-------'<br />

rpad ('Hello', 12, '') -- returns 'Hello'<br />

rpad ('Hello', 12, 'abc') -- returns 'Helloabcabca'<br />

rpad ('Hello', 12, 'abcdefghij') -- returns 'Helloabcdefg'<br />

rpad ('Hello', 2) -- returns 'He'<br />

rpad ('Hello', 2, '-') -- returns 'He'<br />

rpad ('Hello', 2, '') -- returns 'He'<br />

Warning<br />

See also: LPAD()<br />

When used on a BLOB, this function may need to load the entire object into memory. Although it does try to<br />

limit memory consumption, this may affect performance if huge BLOBs are involved.<br />

Available in: DSQL, PSQL<br />

SIGN()<br />

157

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!