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.

Declaration:<br />

External functions (UDFs)<br />

DECLARE EXTERNAL FUNCTION mod<br />

INTEGER, INTEGER<br />

RETURNS DOUBLE PRECISION BY VALUE<br />

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

Library: fbudf<br />

Added in: 1.0 (Win), 1.5 (Linux)<br />

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

*nullif<br />

Description: The four *nullif functions – for integers, bigints, doubles and strings, respectively – each return<br />

the first argument if it is not equal to the second. If the arguments are equal, the functions return NULL.<br />

Result type: Varies, see declarations.<br />

Syntax:<br />

inullif (int1, int2)<br />

i64nullif (bigint1, bigint2)<br />

dnullif (double1, double2)<br />

snullif (string1, string2)<br />

As from <strong>Firebird</strong> 1.5, use of the internal function NULLIF is preferred.<br />

Declarations:<br />

Warnings<br />

• These functions return NULL when the second argument is NULL, even if the first argument is a proper value.<br />

This is a wrong result. The NULLIF internal function doesn't have this bug.<br />

• i64nullif and dnullif will return wrong and/or bizarre results if it is not 100% clear to the engine that<br />

each argument is of the intended type (NUMERIC(18,0) or DOUBLE PRECISION). If in doubt, cast them both<br />

explicitly to the declared type (see declarations below).<br />

DECLARE EXTERNAL FUNCTION inullif<br />

INT BY DESCRIPTOR, INT BY DESCRIPTOR<br />

RETURNS INT BY DESCRIPTOR<br />

ENTRY_POINT 'iNullIf' MODULE_NAME 'fbudf'<br />

DECLARE EXTERNAL FUNCTION i64nullif<br />

NUMERIC(18,4) BY DESCRIPTOR, NUMERIC(18,4) BY DESCRIPTOR<br />

RETURNS NUMERIC(18,4) BY DESCRIPTOR<br />

ENTRY_POINT 'iNullIf' MODULE_NAME 'fbudf'<br />

DECLARE EXTERNAL FUNCTION dnullif<br />

DOUBLE PRECISION BY DESCRIPTOR, DOUBLE PRECISION BY DESCRIPTOR<br />

RETURNS DOUBLE PRECISION BY DESCRIPTOR<br />

ENTRY_POINT 'dNullIf' MODULE_NAME 'fbudf'<br />

182

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

Saved successfully!

Ooh no, something went wrong!