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.

External functions (UDFs)<br />

DECLARE EXTERNAL FUNCTION snullif<br />

VARCHAR(100) BY DESCRIPTOR, VARCHAR(100) BY DESCRIPTOR,<br />

VARCHAR(100) BY DESCRIPTOR RETURNS PARAMETER 3<br />

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

Library: fbudf<br />

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

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

*nvl<br />

Description: The four nvl functions – for integers, bigints, doubles and strings, respectively – are NULL replacers.<br />

They each return the first argument's value if it is not NULL. If the first argument is NULL, the value of the<br />

second argument is returned.<br />

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

Syntax:<br />

invl (int1, int2)<br />

i64nvl (bigint1, bigint2)<br />

dnvl (double1, double2)<br />

snvl (string1, string2)<br />

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

Declarations:<br />

Warning<br />

i64nvl and dnvl will return wrong and/or bizarre results if it is not absolutely clear to the engine that each<br />

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

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

DECLARE EXTERNAL FUNCTION invl<br />

INT BY DESCRIPTOR, INT BY DESCRIPTOR<br />

RETURNS INT BY DESCRIPTOR<br />

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

DECLARE EXTERNAL FUNCTION i64nvl<br />

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

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

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

DECLARE EXTERNAL FUNCTION dnvl<br />

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

RETURNS DOUBLE PRECISION BY DESCRIPTOR<br />

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

183

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

Saved successfully!

Ooh no, something went wrong!