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' ...
随机推荐
- 导入的eclipse 中 maven项目,项目中已经加入lombok.jar包,但是不能编译成功
原文地址:http://bbs.csdn.net/topics/390854507/ 答案是最后一个:单击工程名 Maven->Update Project
- IIS 网站 HTTP 转 HTTPS
最近需要做 http 链接转成 https 链接,所以就去弄了,现在记录下: 1.准备SSL证书 最开始的时候用的是腾讯云的免费证书,有效期1年,但只能绑定一个二级域名.测试成功后,就去阿里云购买了证 ...
- ionic使用iframe时无法显示网页或报错
ionic使用iframe时无法显示网页或报错 Uncaught DOMException: Blocked a frame with origin 在config.xml中添加 <access ...
- centos 中查找文件、目录、内容
1.查找文件 find / -name 'filename'12.查找目录 find / -name 'path' -type d13.查找内容 find . | xargs grep -ri 'co ...
- CAS的单点登录和oauth2的最大区别
CAS的单点登录时保障客户端的用户资源的安全 oauth2则是保障服务端的用户资源的安全 CAS客户端要获取的最终信息是,这个用户到底有没有权限访问我(CAS客户端)的资源. oauth2获取的最终信 ...
- R文本挖掘之jiebaR包
library(jiebaRD)library(jiebaR) ##调入分词的库cutter <- worker()mydata =read.csv(file.choose(),fileEnc ...
- xcode10 改动
xcode10 开发环境 比 之前有了稍微的变动 1. 代码块 界面控件 图片资源等 的查看位置发生了变化 之前的开发环境 代码块 统一放在 右侧栏的下方的几个选项中 现在 统一放到了上方 ...
- $.ajax()方法详解 ajax之async属性 【原创】详细案例解剖——浅谈Redis缓存的常用5种方式(String,Hash,List,set,SetSorted )
$.ajax()方法详解 jquery中的ajax方法参数总是记不住,这里记录一下. 1.url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. 2.type: 要求为Str ...
- linux内核剖析(六)Linux系统调用详解(实现机制分析)
本文介绍了系统调用的一些实现细节.首先分析了系统调用的意义,它们与库函数和应用程序接口(API)有怎样的关系.然后,我们考察了Linux内核如何实现系统调用,以及执行系统调用的连锁反应:陷入内核,传递 ...
- python 验证码识别示例(一) 某个网站验证码识别
某个招聘网站的验证码识别,过程如下 一: 原始验证码: 二: 首先对验证码进行分析,该验证码的数字颜色有变化,这个就是识别这个验证码遇到的比较难的问题,解决方法是使用PIL 中的 getpixel ...