该函数实现过滤前后的指定的字符串,诸如过滤分隔符等。可用于过滤字符串中的逗号分割符。特别说明:substr()函数支持从字符串倒数开始读取,例如:

dbms_output.put_line( substr('Hello World',-3,3));
执行结果:rld
    --过滤字符串前后的多疑字符,诸如过滤字符串前后的多余逗号
Function Fn_DislodgeSplitChar(
P_FacultyList In Varchar2 Default '',
P_FacultyChar In Varchar2 Default '',
P_FacultyType In VARCHAR2 Default ''
)
Return Varchar2
As
v_FacultyList Varchar2(32767) Default '';
v_FacultyChar Varchar2(8000) Default '';
v_FacultyType Varchar2(20) Default '';
v_FacultyListLength Pls_Integer Default 0;
v_FacultyCharLength Pls_Integer Default 0;
Begin
v_FacultyList := Trim(P_FacultyList);
v_FacultyChar := Trim(P_FacultyChar);
v_FacultyType := Trim(P_FacultyType);
v_FacultyListLength := Length(v_FacultyList);
v_FacultyCharLength := Length(v_FacultyChar); If v_FacultyType = 'all' Then
v_FacultyType := 'leftright';
End If; IF v_FacultyListLength > 0 Then
If instr(v_FacultyType,'left') > 0 And Substr(v_FacultyList,1,v_FacultyCharLength) = v_FacultyChar Then
v_FacultyList := Substr(v_FacultyList, -1, v_FacultyListLength - v_FacultyCharLength);
End If; If instr(v_FacultyType,'right') > 0 And Substr(v_FacultyList,-v_FacultyCharLength, v_FacultyCharLength) = v_FacultyChar Then
v_FacultyList := Substr(v_FacultyList,1,v_FacultyListLength - v_FacultyCharLength);
End If;
End If; Return v_FacultyList;
End Fn_DislodgeSplitChar;

oracle过滤分割字符串自定义函数的更多相关文章

  1. oracle正则截取字符串的函数

    现在有这么一个需求, 数据库中的一个手输的'籍贯'字段,要按一定的规范截取显示在报表上,比如,如果'籍贯'的内容是:'山东省潍坊市昌乐县', 那么报表里要显示为:'山东昌乐', 如果'籍贯'是山东省潍 ...

  2. 【oracle】oracle REGEXP_SUBSTR分割字符串

    REGEXP_SUBSTR的使用:通过REGEXP_SUBSTR进行数据分割: , LEVEL, 'i') AS STR FROM DUAL CONNECT BY LEVEL <= LENGTH ...

  3. Oracle数据库分割字符串function方法

    下面我直接上传一串代码源码, create or replace function strsplit(p_value varchar2, p_split varchar2 := ',') --usag ...

  4. oracle 数据库 分割字符串返回结果集函数

    CREATE OR REPLACE FUNCTION "UFN_SPLIT" (      p_list varchar2,      p_sep varchar2 := ',' ...

  5. Oracle 正则表达式 分割字符串

    inData='12345|张三|男' SELECT REGEXP_SUBSTR (inData, '[^|]+', 1,1) into 用户ID FROM DUAL;SELECT REGEXP_SU ...

  6. Oracle多行记录合并自定义函数

    在oracle数据库中,进行字段合并,可以使用wm_concat(column)函数,但是在这种方法不被Oracle所推荐,因为WMSYS用户用于Workspace Manager,其函数对象可能因版 ...

  7. Delphi中常用字符串处理函数

    .copy(str,pos,num) 从str字符串的pos处开始,截取num个字符的串返回. 假设str为,)=,)='def' .concat(str1,str2{,strn}) 把各自变量连接起 ...

  8. SQL Server中自定义函数:用指定的分隔符号分割字符串

    微软SQL Server数据库中包含了很多内置的函数,入下图: 它们用于处理日期.数学.元数据.字符串等. 其中最为常用的就是处理字符串,里面包含了CharIndex()等函数,非常方便使用. 但是对 ...

  9. 模拟java的split函数,分割字符串,类似于java的split方法

    /*自定义oracle的分割函数*//*定义一个type,用户接收返回的数据集合类型*/create or replace type splitType as table of varchar2(40 ...

随机推荐

  1. jackson学习----解析豆瓣的图书信息

      异常一. org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [simple ...

  2. Gogs:可能是比Gitlab更好的选择

    Gitlab是一个很棒的Git托管服务,几乎像GitHub一样强大. 但是,有没有能和Gitlab/Github媲美但操作更简单的项目呢?我认为 Gogs 是很好的选择. 简介 现在,GitHub已经 ...

  3. 【LA2796】Concert Hall Scheduling(最大费用最大流)

    Description You are appointed director of a famous concert hall, to save it from bankruptcy. The hal ...

  4. Spring MVC 解读——<mvc:annotation-driven/>(转)

    转自:http://my.oschina.net/HeliosFly/blog/205343 Spring MVC 解读——<mvc:annotation-driven/> 一.Annot ...

  5. SSH自定义标签

     一.标签处理类:package cn.conris.sys.form; import java.io.IOException; import java.util.Enumeration; impor ...

  6. leetcode面试准备: Jump Game

    1 题目 Given an array of non-negative integers, you are initially positioned at the first index of the ...

  7. tomcat 系统架构与设计模式 第一部分 系统架构工作原理 转

    Tomcat 系统架构与设计模式,第 1 部分: 工作原理 许 令波, Java 开发工程师, 淘宝网 许令波,现就职于淘宝网,是一名 Java 开发工程师.对大型互联网架构设计颇感兴趣,并对一些开源 ...

  8. mysql优化, 删除数据后物理空间未释放(转载)

    mysql优化, 删除数据后物理空间未释放(转载) OPTIMIZE TABLE 当您的库中删除了大量的数据后,您可能会发现数据文件尺寸并没有减小.这是因为删除操作后在数据文件中留下碎片所致.OPTI ...

  9. Android+clipse导入工程提示:invalid project description

    今天遇到一个奇怪的问题.一个android的工程用eclipse导入的时候,提示错误.错误为:invalid project description . details为xxxx project ov ...

  10. 网络流CodeForces. Original 589F:Gourmet and Banquet

    A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet kno ...