Oracle 5.0 Reference Manual page 2832

Table of Contents

Advertisement

double xxx(UDF_INIT *initid, UDF_ARGS *args,
char *is_null, char *error);
functions return string values and should be declared the same way as
DECIMAL
functions are not implemented.
ROW
The initialization and deinitialization functions are declared like this:
my_bool xxx_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
void xxx_deinit(UDF_INIT *initid);
The
parameter is passed to all three functions. It points to a
initid
used to communicate information between functions. The
initialization function should fill in any members that it wishes to change. (To use the default for a
member, leave it unchanged.)
my_bool maybe_null
should set
xxx_init()
the arguments are declared maybe_null.
unsigned int decimals
The number of decimal digits to the right of the decimal point. The default value is the maximum
number of decimal digits in the arguments passed to the main function. For example, if the function is
passed 1.34, 1.345, and 1.3, the default would be 3, because
For arguments that have no fixed number of decimals, the
more than the maximum number of decimals permitted for the DECIMAL, FLOAT, and
types.
A
value of 31 is used for arguments in cases such as a
decimals
declared without an explicit number of decimals (for example,
and for floating-point constants such as 1345E-3. It is also used for string and other nonnumber
arguments that might be converted within the function to numeric form.
The value to which the
function to reflect the actual calculation performed. The default is determined such that the largest
number of decimals of the arguments is used. If the number of decimals is 31 for even one of the
arguments, that is the value used for decimals.
unsigned int max_length
The maximum length of the result. The default
type of the function. For string functions, the default is the length of the longest argument. For integer
functions, the default is 21 digits. For real functions, the default is 13 plus the number of decimal
digits indicated by initid->decimals. (For numeric functions, the length includes any sign or
decimal point characters.)
If you want to return a blob value, you can set
allocated, but the value is used to decide which data type to use if there is a need to temporarily
store the data.
char *ptr
A pointer that the function can use for its own purposes. For example, functions can use
to communicate allocated memory among themselves.
>ptr
memory and assign it to this pointer:
initid->ptr = allocated_memory;
In
and xxx_deinit(), refer to
xxx()
Adding a New User-Defined Function
to
if
maybe_null
1
member is initialized is only a default. It can be changed within the
decimals
initid->ptr
2812
UDF_INIT
structure members follow. The
UDF_INIT
can return NULL. The default value is
xxx()
1.345
decimals
FLOAT
FLOAT
value differs depending on the result
max_length
to 65KB or 16MB. This memory is not
max_length
xxx_init()
to use or deallocate the memory.
functions.
STRING
structure that is
1
has 3 decimal digits.
value is set to 31, which is 1
DOUBLE
or
column
DOUBLE
rather than FLOAT(10,3))
initid-
should allocate the
if any of
data

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents