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.

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

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

External functions (UDFs)<br />

Description: Returns the input string with any leading space characters removed. In new code, you are advised<br />

to use the internal function TRIM instead, as it is both more powerful and more versatile.<br />

Result type: VARCHAR(n)<br />

Syntax (unchanged):<br />

ltrim (str)<br />

Declaration:<br />

Notes:<br />

DECLARE EXTERNAL FUNCTION ltrim<br />

CSTRING(255) NULL<br />

RETURNS CSTRING(255) FREE_IT<br />

ENTRY_POINT 'IB_UDF_ltrim' 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 />

the engine will pass a NULL argument value unchanged to the function. This leads to a NULL result,<br />

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

to the function as an empty string and the result is an empty string as well.<br />

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

• Depending on how you declare it (see CSTRING note), this function can accept and return strings of up to<br />

32767 characters.<br />

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

• In <strong>Firebird</strong> 1.5.1 and below, the default declaration used CSTRING(80) instead of CSTRING(255).<br />

• In <strong>Firebird</strong> 1.0.x, this function returned NULL if the input string was either empty or NULL.<br />

Library: ib_udf<br />

Added in: IB<br />

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

mod<br />

Description: Returns the remainder of an integer division.<br />

Result type: DOUBLE PRECISION<br />

Syntax:<br />

mod (a, b)<br />

181

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

Saved successfully!

Ooh no, something went wrong!