Subject Re: JDBC function mapping
Author Ian A. Newby
Hi Roman,
Most functions cannot be done without a UDF library in place. If
it is in place you could check for the correct entry point in the
system tables and use it, otherwise return not supported?

the following SQL with list the entry points in the ib_udf.dll

select upper(f.rdb$entrypoint), f.rdb$function_name from
rdb$functions f where upper(f.rdb$module_name) like 'IB_UDF%'

You would just need to map the jdbc function name to the entry point
and replace it with the function name from the above sql.

> -------------------------
> ABS(number) - Available in ib_udf
> ACOS(float) - Available in ib_udf
> ASIN(float) - Available in ib_udf
> ATAN(float) - Available in ib_udf
> ATAN2(float1, float2) - Available in ib_udf
> CEILING(number) - Available in ib_udf
> COS(float) - Available in ib_udf
> COT(float) - Available in ib_udf
> DEGREES(number) -
> EXP(float) -
> FLOOR(number) - Available in ib_udf
> LOG(float) - Available in ib_udf as ln if log is
natural log
> LOG10(float) - Available in ib_udf as Log(10,y) where
> MOD(integer1, integer2) - Available in ib_udf
> PI() -
> POWER(number, power) -
> RADIANS(number) -
> RAND(integer) - Available in ib_udf (But I think it
doesn't work
> ROUND(number, places) -
> SIGN(number) - Available in ib_udf
> SIN(float) - Available in ib_udf
> SQRT(float) - Available in ib_udf
> TAN(float) - Available in ib_udf
> TRUNCATE(number, places) - cast(number, as decimal(16,places))
>
> String functions
> ----------------------------
> ASCII(string) - Available in ib_udf (asscii_val)
> CHAR(code) - Available in ib_udf (asscii_char)
> CONCAT(string1, string2) - string1 || string2
> DIFFERENCE(string1, string2) -
> INSERT(string1, start, length, string2) - SUBSTRING(string1 FROM 1
FOR start) || SUBSTRING(string2 FROM 1 FOR length) || SUBSTRING
(string1 FROM start FOR 32000)
> LCASE(string) - LOWER(string)
> LEFT(string, count) - SUBSTRING(string FROM 1 FOR count)
> LENGTH(string) - Available in ib_udf (strlen)
> LOCATE(string1, string2[, start]) -
> LTRIM(string) - Available in ib_udf
> REPEAT(string, count) -
> REPLACE(string1, string2, string3) -
> RIGHT(string, count) - SUBSTRING(string FROM strlen
(string) - count FOR strlen(string))
> RTRIM(string) - Available in ib_udf
> SOUNDEX(string) -
> SPACE(count) -
> SUBSTRING(string, start, length) - SUBSTRING(string FROM start FOR
length)
> UCASE(string) - UPPER(string)
>
> Date/Time functions:
> -------------------------------
> CURDATE() - current_date (only dialect 3)
> CURTIME() - current_time (only dialect 3)
> DAYNAME(date) -
> DAYOFMONTH(date) -
> DAYOFWEEK(date) -
> DAYOFYEAR(date) - extract(day from date)
> HOUR(time) - extract(hour from time)
> MINUTE(time) - extract(minute from time)
> MONTH(date) - extract(month from date)
> MONTHNAME(date) -
> NOW() - current_timestamp or 'now'
> QUARTER(date) -
> SECOND(time) - extract(second from time)
> TIMESTAMPADD(interval, timestamp) -
> TIMESTAMPDIFF(interval, timestamp1, timestamp2) -
> WEEK(date) -
> YEAR(date) - extract(year from date)
>
> System functions:
> ----------------------------------
> DATABASE() -
> IFNULL(expression, value) - COALESCE(expression, value)

Regards
Ian Newby