Firebird Documentation IndexFirebird 2.1 Language Ref. UpdateExternal functions (UDFs) → ascii_char
Firebird Home Firebird Home Prev: addYearFirebird Documentation IndexUp: External functions (UDFs)Next: ascii_val

ascii_char

Library: ib_udf

Changed in: 1.0, 2.0

Better alternative: Internal function ASCII_CHAR()

Description: Returns the ASCII character corresponding to the integer value passed in.

Result type: VARCHAR(1)

Syntax (unchanged): 

ascii_char (intval)

Declaration: 

DECLARE EXTERNAL FUNCTION ascii_char
   INTEGER NULL
   RETURNS CSTRING(1) FREE_IT
   ENTRY_POINT 'IB_UDF_ascii_char' MODULE_NAME 'ib_udf'

The declaration reflects the fact that the UDF as such returns a 1-character C string, not an SQL CHAR(1) as stated in the InterBase declaration. The engine will pass the result to the caller as a VARCHAR(1) though.

The NULL after INTEGER is an optional addition that became available in Firebird 2. When declared with the NULL keyword, the engine will pass a NULL argument unchanged to the function. This causes a NULL result, which is correct. Without the NULL keyword (your only option in pre-2.0 versions), NULL is passed to the function as 0 and the result is an empty string.

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

Notes: 

Prev: addYearFirebird Documentation IndexUp: External functions (UDFs)Next: ascii_val
Firebird Documentation IndexFirebird 2.1 Language Ref. UpdateExternal functions (UDFs) → ascii_char