1>自定义比较函数,targetVal的值为字符串,例如:“>=90”,"2~8"等范围格式,dataVal值为字符串。

create or replace function compare1(targetVal in varchar2,
dataVal in varchar2) return integer is
v_Result integer;
dataVal_int number;
targetVal_int number;
v_targetVal varchar2(200);
v_dataVal varchar2(200);
v_flag boolean;
v_index integer;
begin
v_flag := true;
v_targetVal := replace(targetVal, ' ');
v_dataVal := replace(dataVal, ' ');
dataVal_int := to_number(v_dataVal);
if instr(v_targetVal, '>=') > 0 then
v_targetVal := replace(v_targetVal, '>=');
targetVal_int := to_number(v_targetVal);
v_flag := dataVal_int >= targetVal_int;
elsif instr(v_targetVal, '>') > 0 then
v_targetVal := replace(v_targetVal, '>');
targetVal_int := to_number(v_targetVal);
v_flag := dataVal_int > targetVal_int;
elsif instr(v_targetVal, '<=') > 0 then
v_targetVal := replace(v_targetVal, '<=');
targetVal_int := to_number(v_targetVal);
v_flag := dataVal_int <= targetVal_int;
elsif instr(v_targetVal, '<') > 0 then
v_targetVal := replace(v_targetVal, '<');
targetVal_int := to_number(v_targetVal);
v_flag := dataVal_int < targetVal_int;
elsif instr(v_targetVal, '~') > 0 then
v_index := instr(v_targetVal, '~');
v_flag := dataVal_int <= to_number(substr(v_targetVal, v_index + 1)) and
dataVal_int >=
to_number(substr(v_targetVal, 1, v_index - 1));
elsif instr(v_targetVal, '=') > 0 then
v_targetVal := replace(v_targetVal, '=');
targetVal_int := to_number(v_targetVal);
v_flag := dataVal_int = targetVal_int;
elsif instr(v_targetVal, '=') = 0 then
targetVal_int := to_number(v_targetVal);
v_flag := dataVal_int = targetVal_int;
end if;
if v_flag then
v_Result := 1;
else
v_Result := 0;
end if;
return(v_Result);
exception
when others then
return 1;
end compare1;

程序员的基础教程:菜鸟程序员

oracle 自定义比较函数的更多相关文章

  1. oracle 自定义 聚合函数

    Oracle自定义聚合函数实现字符串连接的聚合   create or replace type string_sum_obj as object ( --聚合函数的实质就是一个对象      sum ...

  2. Oracle自定义数据类型 1

    原文 oracle 自定义类型 type / create type 一 Oracle中的类型 类型有很多种,主要可以分为以下几类: 1.字符串类型.如:char.nchar.varchar2.nva ...

  3. Mybatis下配置调用Oracle自定义函数返回的游标结果集

    在ibatis和Mybatis对存储过程和函数函数的调用的配置Xml是不一样的,以下是针对Mybatis 3.2的环境进行操作的. 第一步配置Mapper的xml内容 <mapper names ...

  4. 【C++】自定义比较函数小结

    1.使用结构体grid作为map的key struct grid { int x; int y; }; (1)需要自定义比较函数operator<,不然会报错: error C2784: “bo ...

  5. 【转】Oracle 自定义函数语法与实例

    原文地址:https://blog.csdn.net/libertine1993/article/details/47264211 Oracle自定义函数的语法如下: create or replac ...

  6. Oracle自定义函数和存储过程示例,自定义函数与存储过程区别

    参考资料:http://www.newbooks.com.cn/info/60861.html oracle自定义函数学习和连接运算符(||) 贴一段中文文档示例,应该就可以开始工作了: --过程(P ...

  7. 对于一些stl自定义比较函数

    1.unorderd_map自定义键 自定义类型 struct my_key { int num; string name; }; 1.由于unordered_map是采用哈希实现的,对于系统的类型i ...

  8. ORACLE 自定义聚合函数

    用户可以自定义聚合函数  ODCIAggregate,定义了四个聚集函数:初始化.迭代.合并和终止. Initialization is accomplished by the ODCIAggrega ...

  9. ORACLE自定义顺序排序-转

    ORACLE可以借助DECODE函数,自定义顺序排序: select * from ( select 'Nick' as item from dual union all select 'Viki' ...

随机推荐

  1. 倾斜摄影数据OSGB进入到ArcGIS平台相关问题小结

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/zglybl/article/details/75252288      随着倾斜摄影技术的发展,大家 ...

  2. Python计算分位数

    Python计算分位数    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/gdkyxy2013/article/details/80911514 ...

  3. JS 之 阻止事件冒泡,阻止默认事件,event.stopPropagation()和event.preventDefault(),return false的区别

    在前端开发中,有时我们需要阻止冒泡和阻止默认事件的发生. 一.event.stopPropagation() 阻止事件的冒泡,不让事件向documen上蔓延,但是默认事件任然会执行,当调用这个方法的时 ...

  4. 需要看源码的java类

    1.数据结构相关的类,如String.ArrayList,LinkedList,HashMap和ConcurrentHashMap等等.2.线程并发相关的类,如Synchronized.Reentra ...

  5. Ant之build.xml配置详解【转】

    原文:https://blog.csdn.net/mevicky/article/details/72828554 前言国内关于build.xml的配置资料太零散了,实在是受不了,故而将自己的笔记整理 ...

  6. lua变量作用域

    3.5 – Visibility Rules Lua is a lexically scoped language. The scope of a local variable begins at t ...

  7. [转]numpy 100道练习题

    100 numpy exercise 翻译:YingJoy 网址: https://www.yingjoy.cn/ 来源:https://github.com/rougier/numpy-100 Nu ...

  8. CAShapeLayer(UIBezierPath)、CAGradientLayer绘制动态小车

    看到一个大神写的代码,引用过来让大家看看! //  1.CAShapeLayer是一种特殊的层,可以在上面渲染图形. //  2.CAShapeLayer继承自CALayer,可使用CALayer的所 ...

  9. 使用Markdown写作

    简介 Markdown是一种轻量级标记语言,创始人为约翰·格鲁伯(John Gruber).它允许人们"使用易读易写的纯文本格式编写文档,然后转换成有效的XHTML(或者HTML)文档&qu ...

  10. RSA 分段加解密【解决“不正确的长度”的异常】

    RSA 是常用的非对称加密算法.最近使用时却出现了“不正确的长度”的异常,研究发现是由于待加密的数据超长所致. .NET Framework 中提供的 RSA 算法规定: 待加密的字节数不能超过密钥的 ...