stored-procedures - 替换 Apache Derby 中的字符串

标签 stored-procedures replace derby sql-function

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

我正在寻找类似的东西:

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

最佳答案

Apache Derby 没有 native 函数,但可以使用 Apache Commons Lang 库创建一个函数。

here 下载 Lang 库

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

还有许多其他有用的功能 here

关于stored-procedures - 替换 Apache Derby 中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37952683/

相关文章:

java - 尝试运行 derby 时 Eclipse 上出现 "Could not find or load main class org.apache.derby.tools.ij"

azure - 并行执行 DocumentDb 存储过程

PHP 替换符号所有可能的变体

apache-spark - 如何从 Spark Shell 中删除 derby.log、metastore_db

replace - Google表格中的自动查找和替换脚本 - 删除某些特定单元格内容 - 全局替换

php - 使用 php 替换 css 中的前导点和斜线

sql - 在 SQL (Derby DB) 中将一些存储为 LONG (BIGINT) 的日期与 YEAR 进行比较的最简单方法

Mysql存储过程错误1064

sql - 如何在 Visual Studio 中设置 SQL 数据库项目中的数据库连接字符串?

sql-server - 如何减少 SQL Server 中并发 DELETE 和 INSERT 到单个表期间的阻塞