oracle 字符串中去掉重复的字符串
2015-12-30 17:00
501 查看
create or replace function MyReplace(oldStr varchar2, sign varchar2) return varchar2 is
str varchar2(1000);
currentIndex number;
startIndex number;
endIndex number;
type str_type is table of varchar2(30)
index by binary_integer;
arr str_type;
Result varchar2(1000);
begin
if oldStr is null then
return ('');
end if;
str := oldStr;
currentIndex := 0;
startIndex := 0;
loop
currentIndex := currentIndex + 1;
endIndex := instr(str, sign, 1, currentIndex);
if (endIndex <= 0) then
exit;
end if;
arr(currentIndex) := trim(substr(str, startIndex + 1, endIndex - startIndex - 1));
startIndex := endIndex;
end loop;
arr(currentIndex) := substr(str, startIndex + 1, length(str));
for i in 1.. currentIndex - 1 loop
for j in i + 1..currentIndex loop
if arr(i) = arr(j) then
arr(j) := '';
end if;
end loop;
end loop;
str := '';
for i in 1..currentIndex loop
if arr(i) is not null then
str := str || sign || arr(i);
arr(i) := '';
end if;
end loop;
Result := substr(str, 2, length(str));
return(Result);
end MyReplace;
str varchar2(1000);
currentIndex number;
startIndex number;
endIndex number;
type str_type is table of varchar2(30)
index by binary_integer;
arr str_type;
Result varchar2(1000);
begin
if oldStr is null then
return ('');
end if;
str := oldStr;
currentIndex := 0;
startIndex := 0;
loop
currentIndex := currentIndex + 1;
endIndex := instr(str, sign, 1, currentIndex);
if (endIndex <= 0) then
exit;
end if;
arr(currentIndex) := trim(substr(str, startIndex + 1, endIndex - startIndex - 1));
startIndex := endIndex;
end loop;
arr(currentIndex) := substr(str, startIndex + 1, length(str));
for i in 1.. currentIndex - 1 loop
for j in i + 1..currentIndex loop
if arr(i) = arr(j) then
arr(j) := '';
end if;
end loop;
end loop;
str := '';
for i in 1..currentIndex loop
if arr(i) is not null then
str := str || sign || arr(i);
arr(i) := '';
end if;
end loop;
Result := substr(str, 2, length(str));
return(Result);
end MyReplace;
相关文章推荐
- oracle 分组查询取第一条数据 关联查询 最后一条数据
- oracle 去除重复字符串函数
- JMeter学习(八)JDBC测试计划-连接Oracle
- oracle SELECT INTO 和 INSERT INTO SELECT 两种表复制语句详解
- 迁移ORACLE_HOME引发的登录sqlplus无法加载类库错误
- ORACLE触发器详解
- oracle查询锁和杀锁
- Oracle中的日期
- oracle 任务计划运行带参数的procedure
- ORA-01843: 无效的月份 ORACLE导入报错
- oracle数据库中导入Excel表格中的数据
- Oracle
- sql server ,mysql ,oracle 自增长字段设置以及自增长属性的修改验证
- Oracle12c中性能优化&功能增强新特性之重大突破——内存列存储新特性
- oracle11g复合分区创建方法(Interval版)
- Linux下通过脚本自动备份Oracle数据库并删除指定天数前的备份
- OracleHelper数据库事务处理
- Oracle 分区表详解(oracle partition table)
- oracle sleep
- oracle没法编译对象