Firebird 2.1 Language Reference Update
Firebird 2.1 Language Reference Update
Firebird 2.1 Language Reference Update
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Internal functions<br />
This will return the average weight of the persons listed in FatPeople, excluding those having a weight of -1,<br />
since AVG skips NULL data. Presumably, -1 indicates “weight unknown” in this table. A plain AVG(Weight)<br />
would include the -1 weights, thus skewing the result.<br />
Note<br />
In <strong>Firebird</strong> 1.0.x, where NULLIF is not available, you can accomplish the same with the *nullif external<br />
functions.<br />
Available in: DSQL, PSQL<br />
Added in: 2.0<br />
Changed in: <strong>2.1</strong><br />
OCTET_LENGTH()<br />
Description: Gives the length in bytes (octets) of the input string. For multi-byte character sets, this may<br />
be less than the number of characters times the “formal” number of bytes per character as found in RDB<br />
$CHARACTER_SETS.<br />
Note<br />
With arguments of type CHAR, this function takes the entire formal string length (e.g. the declared length of a<br />
field or variable) into account. If you want to obtain the “logical” byte length, not counting the trailing spaces,<br />
right-TRIM the argument before passing it to OCTET_LENGTH.<br />
Result type: INTEGER<br />
Syntax:<br />
OCTET_LENGTH (str)<br />
BLOB support: Since <strong>Firebird</strong> <strong>2.1</strong>, this function fully supports text BLOBs of any length and character set.<br />
Examples:<br />
select octet_length('Hello!') from rdb$database<br />
-- returns 6<br />
select octet_length(_iso8859_1 'Grüß di!') from rdb$database<br />
-- returns 8: ü and ß take up one byte each in ISO8859_1<br />
select octet_length<br />
(cast (_iso8859_1 'Grüß di!' as varchar(24) character set utf8))<br />
from rdb$database<br />
-- returns 10: ü and ß take up two bytes each in UTF8<br />
select octet_length<br />
(cast (_iso8859_1 'Grüß di!' as char(24) character set utf8))<br />
from rdb$database<br />
-- returns 26: all 24 CHAR positions count, and two of them are 2-byte<br />
147