Oracle 5.0 Reference Manual page 2834

Table of Contents

Advertisement

whether the
points to a single-byte variable, not to a string buffer.
is reset for each group (before calling xxx_clear()).
*is_null
If
*is_null
function.
21.2.2.3. UDF Argument Processing
The
parameter points to a
args
unsigned int arg_count
The number of arguments. Check this value in the initialization function if you require your function to
be called with a particular number of arguments. For example:
if (args->arg_count != 2)
{
strcpy(message,"XXX() requires two arguments");
return 1;
}
For other
to array members using index values from 0 to
enum Item_result *arg_type
A pointer to an array containing the types for each argument. The possible type values are
STRING_RESULT, INT_RESULT, REAL_RESULT, and DECIMAL_RESULT.
To make sure that arguments are of a given type and return an error if they are not, check the
arg_type
if (args->arg_type[0] != STRING_RESULT ||
args->arg_type[1] != INT_RESULT)
{
strcpy(message,"XXX() requires a string and an integer");
return 1;
}
Arguments of type
way as
STRING_RESULT
As an alternative to requiring your function's arguments to be of particular types, you can use the
initialization function to set the
coerce arguments to those types for each call to xxx(). For example, to specify that the first two
arguments should be coerced to string and integer, respectively, do this in xxx_init():
args->arg_type[0] = STRING_RESULT;
args->arg_type[1] = INT_RESULT;
Exact-value decimal arguments such as
DECIMAL_RESULT. However, the values are passed as strings. If you want to receive a number, use
the initialization function to specify that the argument should be coerced to a
args->arg_type[2] = REAL_RESULT;
Adding a New User-Defined Function
function should return NULL. You should not store a string into *error!
xxx()
or
are set when
*error
UDF_ARGS
member values that are arrays, array references are zero-based. That is, refer
UDF_ARGS
array in the initialization function. For example:
DECIMAL_RESULT
values.
arg_type
Note
Prior to MySQL 5.0.3, decimal arguments were passed as
values. If you upgrade to a newer version and find that your UDF now
receives string values, use the initialization function to coerce the arguments
to numbers as just described.
returns, MySQL returns
xxx()
structure that has the members listed here:
args->arg_count
are passed as strings, so you should handle them the same
elements to the types you want. This causes MySQL to
or
column values are passed with a type of
1.3
DECIMAL
2814
is never reset.
*error
as the result for the group
NULL
– 1.
REAL_RESULT
REAL_RESULT
error
value:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents