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.

Library: ib_udf<br />

Changed in: 1.0, 2.0<br />

Better alternative: Internal function ASCII_CHAR()<br />

External functions (UDFs)<br />

ascii_char<br />

Description: Returns the ASCII character corresponding to the integer value passed in.<br />

Result type: VARCHAR(1)<br />

Syntax (unchanged):<br />

ascii_char (intval)<br />

Declaration:<br />

Notes:<br />

DECLARE EXTERNAL FUNCTION ascii_char<br />

INTEGER NULL<br />

RETURNS CSTRING(1) FREE_IT<br />

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

The declaration reflects the fact that the UDF as such returns a 1-character C string, not an SQL<br />

CHAR(1) as stated in the InterBase declaration. The engine will pass the result to the caller as a<br />

VARCHAR(1) though.<br />

The NULL after INTEGER is an optional addition that became available in <strong>Firebird</strong> 2. When declared<br />

with the NULL keyword, the engine will pass a NULL argument unchanged to the function. This causes<br />

a NULL result, which is correct. Without the NULL keyword (your only option in pre-2.0 versions),<br />

NULL is passed to the function as 0 and the result is an empty string.<br />

For more information about passing NULLs to UDFs, see the note at the end of this book.<br />

• ascii_char(0) returns an empty string in all versions, not a character with ASCII value 0.<br />

• Before <strong>Firebird</strong> 2.0, the result type was CHAR(1).<br />

Library: ib_udf<br />

Added in: IB<br />

Better alternative: Internal function ASCII_VAL()<br />

ascii_val<br />

169

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

Saved successfully!

Ooh no, something went wrong!