编译:
cd $HOME/sqllib/samples/c
bldrtn TrimChr <dbname>
cp TrimChr $HOME/sqllib/function/
重启数据库
简单测试结果:
=> db2 "select * from lt"
C1 C2
------------------------ --------------------
+2.00000000000000E+000 eeee
+4.00000000000000E+000 asdf
+3.00000000000000E+000 -
3 record(s) selected.
=> db2 "select c1, trimchr(c2) from lt";
C1 2
------------------------ ----------
+2.00000000000000E+000 eeee
+4.00000000000000E+000 asdf
+3.00000000000000E+000 -
cd $HOME/sqllib/samples/c
bldrtn TrimChr <dbname>
cp TrimChr $HOME/sqllib/function/
重启数据库
简单测试结果:
=> db2 "select * from lt"
C1 C2
------------------------ --------------------
+2.00000000000000E+000 eeee
+4.00000000000000E+000 asdf
+3.00000000000000E+000 -
3 record(s) selected.
=> db2 "select c1, trimchr(c2) from lt";
C1 2
------------------------ ----------
+2.00000000000000E+000 eeee
+4.00000000000000E+000 asdf
+3.00000000000000E+000 -
3 record(s) selected.
JAVA自定义函数
drop function ids.regexJ;
create function ids.regexJ(regex VARCHAR(2048),src VARCHAR(2048))
returns integer
fenced
variant
no sql
language java
parameter style java
external name 'RegTest!regexUdf';
编写java类程序然后编译成可执行文件UserFunction.class*,chmod 文件权限后
在执行第二步,JAVA类文件放在/home/db2inst1/sqllib/function/ DB2的安装目录
以上2种方式都试过,第一个Pcre编译完成,执行过程有问题,第二个DB2 JAVA版本1.3.1 也是报错。
郁闷