I have written a Java UDF for DB2 and registered it using the following params:
CREATE FUNCTION WASG2.arsu_bit_value ( varchar(32) for bit data, integer ) RETURNS INTEGER EXTERNAL NAME 'ch.ips.g2.db2.ch.ips.g2.db2.ARSU_BIT_VALUE!arsu_b it_value'
LANGUAGE java PARAMETER STYLE db2general DETERMINISTIC NOT FENCED NOT NULL CALL NO SQL NO EXTERNAL ACTION SCRATCHPAD
NO FINAL CALL ALLOW PARALLEL NO DBINFO
Basically the function returns the value (0 or 1) of the specified bit in a bit array.
Example of usage:
-- returns all arsu rights that have the 254-th bit set to 1 (LIST is varchar(32) for bit data)
select * from arsu_list where ARSU_BIT_VALUE(LIST, 254)=1
The functions itself works fine and is relatively fast (<1ms per invocation), however, DB2 seems to "insert" approx. 170 ms delays in between individual method invocations. It is a simple select so what is DB2 is doing during this time?