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.

Library: ib_udf<br />

Added in: IB<br />

External functions (UDFs)<br />

strlen<br />

Better alternatives: Internal functions BIT_LENGTH(), CHAR[ACTER]_LENGTH and OCTET_LENGTH()<br />

Description: Returns the length of the argument string.<br />

Result type: INTEGER<br />

Syntax:<br />

strlen (str)<br />

Declaration:<br />

DECLARE EXTERNAL FUNCTION strlen<br />

CSTRING(32767)<br />

RETURNS INTEGER BY VALUE<br />

ENTRY_POINT 'IB_UDF_strlen' MODULE_NAME 'ib_udf'<br />

Library: ib_udf<br />

Changed in: 1.0, 1.5.2, 2.0<br />

substr<br />

Description: Returns a string's substring from startpos to endpos, inclusively. Positions are 1-based. If endpos<br />

is past the end of the string, substr returns all the characters from startpos to the end of the string. This<br />

function only works correctly with single-byte characters.<br />

Result type: VARCHAR(n)<br />

Syntax (unchanged):<br />

substr (str, startpos, endpos)<br />

Declaration:<br />

DECLARE EXTERNAL FUNCTION substr<br />

CSTRING(255) NULL, SMALLINT, SMALLINT<br />

RETURNS CSTRING(255) FREE_IT<br />

ENTRY_POINT 'IB_UDF_substr' MODULE_NAME 'ib_udf'<br />

The above declaration is from the file ib_udf2.sql. The NULL after the argument is an optional<br />

addition that became available in <strong>Firebird</strong> 2. If the argument is declared with the NULL keyword,<br />

192

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

Saved successfully!

Ooh no, something went wrong!