替换 Apache Derby 中的字符串 [英] Replace string in Apache Derby

查看:58
本文介绍了替换 Apache Derby 中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache Derby 有办法用另一个字符串替换一个字符串吗?

Does Apache Derby have a way of replacing a string with another string?

我正在寻找类似的东西:

I'm looking for something like:

select
    replace('bruce bogtrotter', 'bruce', 'john')
from SYSIBM.SYSDUMMY1

推荐答案

Apache Derby 没有本机函数,但可以使用 Apache Commons Lang 库创建一个.

Apache Derby doesn't have a native function, but it's possible to create one using by using the Apache Commons Lang library.

此处

call SQLJ.INSTALL_JAR('C:\path_to_libraries\commons-lang3-3.4.jar', 'APP.commons_lang', 0);
call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', 'APP.commons_lang');

create function replace (sourceString varchar(8000), searchString varchar(8000), replaceString varchar(8000))
returns varchar(8000)
parameter style java no sql
language java external name 'org.apache.commons.lang3.StringUtils.replace';

select
    replace('bruce bogtrotter', 'bruce', 'john')
from SYSIBM.SYSDUMMY1

还有许多其他有用的函数这里

There are a number of other useful functions here

这篇关于替换 Apache Derby 中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆