instr oracle函数读作,使用Oracle的Instr()与decode()函数进行多条件组合查询

a4c26d1e5885305701be709a3d33442f.png

使用Oracle的Instr()与decode()函数进行多条件组合查询

(2006-10-25 14:40:40)

系统中遇到了要处理多条件组合查询的情况,使用instr()和decode()函数的实现方法。

下面先说明一下instr()的功能和语法:(函数的语法是从处得到的,相当清晰明了:)

In Oracle/PLSQL, the instr function returns the location of a substring in a string.

The syntax for the instr function is:

instr (string1, string2, [start_position], [nth_appearance])

string1 is the string to search.

string2 is the substring to search for in string1.

start_position is the position in string1 where the search will start. This argument is optional. If omitted, it defaults to 1. The first position in the string is 1. If the start_position is negative, the function counts back start_position number of characters from the end of string1 and then searches towards the beginning of string1.

nth_appearance is the nth appearance of string2. This is optional. If omiited, it defaults to 1.

再说明一下decode()的功能和语法:

In Oracle/PLSQL, the decode function has the functionality of an IF-THEN-ELSE statement.

The syntax for the decode function is:

decode ( expression , search , result [, search , result]... [, default] )

expression is the value to compare.

search is the value that is compared against expression.

result is the value returned, if expression is equal to search.

default is optional. If no matches are found, the decode will return default. If default is omitted, then the decode statement will return null (if no matches are found).

综合使用得到的SQL语句如下:

select e.到达日期,

e.角色名,

d.单据标题,

d.单据编号,

e.节点编号,

e.处理动作,

e.处理日期,

b.流程实例编号

from gzl_流程类型a,

gzl_流程实例b,

gzl_流程定义c,

dj_单据 d,

gzl_流程流转状态 e

where a.流程类型编号 = c.流程类型编号 and e.处理标记 = '是'

and e.用户id = 'tetdmis' and b.流程定义编号 = c.流程定义编号

and b.活动编号 = d.单据编号 and c.流程定义编号 = b.流程定义编号

and e.流程实例编号 = b.流程实例编号

and instr(decode(:流程类型条件, '-1', a.流程类型编号, :流程类型条件), a.流程类型编号) > 0

and (to_char(e.处理日期, 'yyyy-mm-dd') between :开始日期 and :结束日期)

and instr(decode(:节点名称条件, '-1', e.处理动作, :节点名称条件),

e.处理动作) > 0

分享:

a4c26d1e5885305701be709a3d33442f.png喜欢

0

a4c26d1e5885305701be709a3d33442f.png赠金笔

加载中,请稍候......

评论加载中,请稍候...

发评论

登录名: 密码: 找回密码 注册记住登录状态

昵   称:

评论并转载此博文

a4c26d1e5885305701be709a3d33442f.png

发评论

以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值