The InterBase UDF Library

From InterBase

Go Up to Working with UDFs and Blob Filters


InterBase provides a number of frequently needed functions in the form of a UDF library, named ib_udf.dll on Windows platforms and ib_udf on UNIX platforms. This UDF library is located in <<InterBase_home>>/UDF and its functions are all implemented using the standard C library. This section describes each UDF and provides its declaration.

Important notes:

  • Do not move the UDF library file from its installed location unless you also move the utility file that is located in the same directory (ib_util.dll on Windows, ib_util.so on Solaris and Linux). The UDF library file requires the utility file to function correctly.
  • There is a script, ib_udf.sql, in the <<InterBase_home>>/examples/udf directory that declares all of the functions listed below. If you want to declare only a subset of these, copy and edit the script file.
  • Several of these UDFs must be called using the new FREE_IT keyword if, and only if, they are written in thread-safe form, using malloc to allocate dynamic memory.
  • When trigonometric functions are passed inputs that are out of bounds, they return zero rather than NaN.

Below is a list of the functions supplied in the InterBase UDF library. The description and code for each function follow the table.

Function
name
Description Inputs Outputs

abs

Absolute value

Double precision

Double precision

acos

Arc cosine

Double precision

Double precision

ascii_char

Return character based on ASCII code.

Integer

Char(1)

ascii_val

Returns the ASCII value of the character passed in.

Char(1)

Integer

io

Return ASCII code for given character.

Char(1)

Integer

asin

Arc sine

Double precision

Double precision

atan

Arc tangent

Double precision

Double precision

atan2

Arc tangent divided by second argument

Double precision,
Double precision

Double precision

bin_and

Bitwise AND operation

Integer, Integer

Integer

bin_or

Bitwise OR operation

Integer, Integer

Integer

bin_xor

Bitwise XOR operation

Integer, Integer

Integer

ceiling

Round up to nearest whole value.

Double precision

Double precision

cos

Cosine

Double precision

Double precision

cosh

Hyperbolic cosine

Double precision

Double precision

cot

Cotangent

Double precision

Double precision

div

Integer division

Integer

Integer

floor

Round down to nearest whole value.

Double precision

Double precision

ln

Natural logarithm

Double precision

Double precision

log

Logarithm of the first argument, by the base of the second argument.

Double precision,
Double precision

Double precision

log10

Logarithm base 10

Double precision

Double precision

lower

Reduce all upper-case characters to lower-case.

Cstring(80)

Cstring(80)

ltrim

Strip preceding blanks.

Cstring(80)

Cstring(80)

mod

Modulus operation between the two arguments.

Integer, Integer

Integer

pi

Return the value of p.

Double precision

rand

Return a random value.

Double precision

rtrim

Strip trailing blanks.

Cstring(80)

Cstring(80)

sign

Return -1, 0, or 1.

Double precision

Integer

sin

Sine

Double precision

Double precision

sinh

Hyperbolic sine

Double precision

Double precision

sqrt

Square root

Double precision

Double precision

strlen

Length of string

Cstring(80)

Integer

substr

The substring of <s> starting at position <m> and ending at position <n>.

Cstring(80), Smallint,
Smallint

Cstring(80)

tan

Tangent

Double precision

Double precision

tanh

Hyperbolic tangent

Double precision

Double precision

Advance To: