oracle 自定义比较函数
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 自定义比较函数的更多相关文章
- oracle 自定义 聚合函数
Oracle自定义聚合函数实现字符串连接的聚合 create or replace type string_sum_obj as object ( --聚合函数的实质就是一个对象 sum ...
- Oracle自定义数据类型 1
原文 oracle 自定义类型 type / create type 一 Oracle中的类型 类型有很多种,主要可以分为以下几类: 1.字符串类型.如:char.nchar.varchar2.nva ...
- Mybatis下配置调用Oracle自定义函数返回的游标结果集
在ibatis和Mybatis对存储过程和函数函数的调用的配置Xml是不一样的,以下是针对Mybatis 3.2的环境进行操作的. 第一步配置Mapper的xml内容 <mapper names ...
- 【C++】自定义比较函数小结
1.使用结构体grid作为map的key struct grid { int x; int y; }; (1)需要自定义比较函数operator<,不然会报错: error C2784: “bo ...
- 【转】Oracle 自定义函数语法与实例
原文地址:https://blog.csdn.net/libertine1993/article/details/47264211 Oracle自定义函数的语法如下: create or replac ...
- Oracle自定义函数和存储过程示例,自定义函数与存储过程区别
参考资料:http://www.newbooks.com.cn/info/60861.html oracle自定义函数学习和连接运算符(||) 贴一段中文文档示例,应该就可以开始工作了: --过程(P ...
- 对于一些stl自定义比较函数
1.unorderd_map自定义键 自定义类型 struct my_key { int num; string name; }; 1.由于unordered_map是采用哈希实现的,对于系统的类型i ...
- ORACLE 自定义聚合函数
用户可以自定义聚合函数 ODCIAggregate,定义了四个聚集函数:初始化.迭代.合并和终止. Initialization is accomplished by the ODCIAggrega ...
- ORACLE自定义顺序排序-转
ORACLE可以借助DECODE函数,自定义顺序排序: select * from ( select 'Nick' as item from dual union all select 'Viki' ...
随机推荐
- layui常见问题记录
1.用js选中checkbox,没有效果 解决方式:加入 form.render(); 重新渲染表单 $(this).prop('checked', true); //在新版本的jquery中,如果是 ...
- 03、操作RDD(transformation和action案例实战)
1.transformation和action介绍 Spark支持两种RDD操作:transformation和action.transformation操作会针对已有的RDD创建一个新的RDD:而a ...
- Lazarus 初识
Lazarus 使用 Free Pascal 的编译器,支持 Object Pascal 语言,与 Delphi 高度兼容,并看做后者的自由软件替代品. Lazarus 下载与安装 我们先去 Laza ...
- iqiyi__youku__cookie_设置
iqiyi设置cookie var string = "此处替换iqiyi的cookie"; var getCookie = function( str) { var cookie ...
- iis url重写
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.we ...
- c# mvc 封装返回对象
将所有返回JsonContent对象进行再次封装 public class ResultFilterAttribute : System.Web.Mvc.ActionFilterAttribute { ...
- mysql多实例配置下,用脚本启动mysql时,出现Please read "Security" section of the manual to find out how to run mysqld as root!
[root@localhost 3308]# mysqld stop170414 0:35:28 [Note] --secure-file-priv is set to NULL. Operation ...
- 日志分析工具 Log Parser
微软的Log Parser, 下载地址 https://www.microsoft.com/en-us/download/details.aspx?id=24659 支持多种文件格式的分析,输入输出, ...
- 机智的MySQL优化器 --- is null
[介绍] 工作的越久越到的的问题越多,就越是觉得一些“老话”历久弥新:由于最近的学习计划是深入的学习一遍MySQL优化器:学习过程中的一些成果 也会发布到这里,一来是为了整理自己已经知道的和新学到的, ...
- Atitit php java python nodejs错误日志功能的比较
Atitit php java python nodejs错误日志功能的比较 1.1. Php方案 自带 1 1.2. Java解决方案 SLF4J 1 1.3. Python解决方案 自带lo ...