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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Notes:<br />

Internal functions<br />

select trim (leading from ' Waste no space ') from rdb$database<br />

-- returns 'Waste no space '<br />

select trim (leading '.' from ' Waste no space ') from rdb$database<br />

-- returns ' Waste no space '<br />

select trim (trailing '!' from 'Help!!!!') from rdb$database<br />

-- returns 'Help'<br />

select trim ('la' from 'lalala I love you Ella') from rdb$database<br />

-- returns ' I love you El'<br />

select trim ('la' from 'Lalala I love you Ella') from rdb$database<br />

-- returns 'Lalala I love you El'<br />

• If str is a BLOB, the result is a BLOB. Otherwise, it is a VARCHAR(n) with n the formal length of str.<br />

• The substring to be removed, if specified, may not be bigger than 32767 bytes. However, if this substring is<br />

repeated at str's head or tail, the total number of bytes removed may be far greater. (The restriction on the<br />

size of the substring will be lifted in <strong>Firebird</strong> 3.)<br />

Warning<br />

When used on a BLOB, this function may need to load the entire object into memory. This may affect performance<br />

if huge BLOBs are involved.<br />

Available in: DSQL, PSQL<br />

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

TRUNC()<br />

Description: Returns the integer part of a number. With the optional scale argument, the number can be truncated<br />

to powers-of-ten multiples (tens, hundreds, tenths, hundredths, etc.) instead of just integers.<br />

Result type: INTEGER, (scaled) BIGINT or DOUBLE<br />

Syntax:<br />

TRUNC ( [, ])<br />

::= a numerical expression<br />

::= an integer specifying the number of decimal places<br />

toward which should be truncated, e.g.:<br />

2 for truncating to a multiple of 0.01<br />

1 for truncating to a multiple of 0.1<br />

0 for truncating to a whole number<br />

-1 for truncating to a multiple of 10<br />

-2 for truncating to a multiple of 100<br />

162

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

Saved successfully!

Ooh no, something went wrong!