Oracle中Instr函数使用
来源:互联网 发布:360极速浏览器mac下载 编辑:程序博客网 时间:2024/05/01 18:41
INSTR方法的格式为
INSTR(src, subStr,startIndex, count)
src: 源字符串
subStr : 要查找的子串
startIndex : 从第几个字符开始。负数表示从右往左查找。
count: 要找到第几个匹配的序号
返回值: 子串在字符串中的位置,第1个为1;不存在为0. (特别注意:如果src为空字符串,返回值为null)。
用法举例:
最简单的一种,查找l字符,首个l位于第3个位置。
SQL> select instr('hello,java world', 'l') from dual;
INSTR('HELLO,JAVAWORLD','L')
----------------------------
3
查找l字符,从第4个位置开始。
SQL> select instr('hello,java world', 'l', 4) from dual;
INSTR('HELLO,JAVAWORLD','L',4)
------------------------------
4
查找l字符,从第1个位置开始的第3个
SQL> select instr('hello,java world', 'l', 1, 3) from dual;
INSTR('HELLO,JAVAWORLD','L',1,
------------------------------
15
查找l字符,从右边第1个位置开始,从右往左查找第3个(也即是从左到右的第1个)
SQL> select instr('hello,java world', 'l', -1, 3) from dual;
INSTR('HELLO,JAVAWORLD','L',-1
------------------------------
3
找不到返回0
SQL> select instr('hello,java world', 'MM') from dual;
INSTR('HELLO,JAVAWORLD','MM')
-----------------------------
0
源字符为空字符串''的情况
-- Created on 2010-12-22 by CHEN
declare
-- Local variables here
i varchar2(2);
begin
-- Test statements here
i := instr('',',');
if i is null then
dbms_output.put_line(' i is empty');
end if;
end;
结果输出:
i is empty
- Oracle中Instr函数使用
- oracle中instr函数
- oracle中instr函数
- Oracle中instr函数
- Oracle中 instr 函数
- Oracle中 instr 函数
- oracle中instr函数
- Oracle中substr函数和instr函数的结合使用
- Oracle中instr函数用法
- Oracle中instr函数使用方法
- Oracle的instr函数使用
- Oracle的instr函数使用
- instr函数的使用-oracle
- oracle中substrb和instr函数用法
- Oracle中instr函数的用法
- oracle中类似indexof用法 instr函数
- oracle中类似indexof用法 instr函数
- oracle中INSTR函数的用法
- Flex 日期、电话号码、数字、邮编、货币格式化相关
- 编译boost
- 类设计者的核查表
- 字母排序和for each 循环.
- Spring 是什么
- Oracle中Instr函数使用
- Cent OS 5.5 上yum安装Nginx
- 2010BI盘点:加快收购步伐 全面进军BI
- 在WINCE5.0中应用CMD(比如运行PING命令)
- 数据库设计中的一些技巧
- 求日期什么的
- 基于单片机的GPS信息处理系统
- 为什么实模式下段基地址肯定是16的倍数?
- 安装SQL2000时,系统提示之前有挂起的安装操作,要求重启