国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > 綜合 > 正文

使用Instr()與decode()進(jìn)行多條件組合查詢

2024-07-21 02:32:41
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
    系統(tǒng)中碰到了要處理多條件組合查詢的情況,好比說有4個(gè)獨(dú)立的條件,那么組合出的查詢條件便有24種,不可能寫24條Sql語(yǔ)句再分別指定給24種組合情況吧,條件數(shù)再多點(diǎn)呢,人都會(huì)搞瘋的。。。。于是我求助于高手,獲得了使用instr()和decode()函數(shù)的實(shí)現(xiàn)方法。     下面先說明一下instr()的功能和語(yǔ)法:(函數(shù)的語(yǔ)法是從http://www.techonthenet.com/Oracle/functions/index.htm處得到的,相當(dāng)清楚明了:)
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()的功能和語(yǔ)法: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語(yǔ)句如下:select e.到達(dá)日期,
       e.角色名,
       d.單據(jù)標(biāo)題,
       d.單據(jù)編號(hào),
       e.節(jié)點(diǎn)編號(hào),
       e.處理動(dòng)作,
       e.處理日期,
       b.流程實(shí)例編號(hào)  from gzl_流程類型     a,
       gzl_流程實(shí)例     b,
       gzl_流程定義     c,
       dj_單據(jù)          d,
       gzl_流程流轉(zhuǎn)狀態(tài) e
 where a.流程類型編號(hào) = c.流程類型編號(hào) and e.處理標(biāo)記 = '是'
       and   e.用戶id = 'tetdmis' and b.流程定義編號(hào) = c.流程定義編號(hào)    
       and b.活動(dòng)編號(hào) = d.單據(jù)編號(hào) and c.流程定義編號(hào) = b.流程定義編號(hào)
       and  e.流程實(shí)例編號(hào) = b.流程實(shí)例編號(hào)
    
  and instr(decode(:流程類型條件, '-1', a.流程類型編號(hào), :流程類型條件), a.流程類型編號(hào)) > 0
      and (to_char(e.處理日期, 'yyyy-mm-dd') between :開始日期 and :結(jié)束日期)      
       and instr(decode(:節(jié)點(diǎn)名稱條件, '-1', e.處理動(dòng)作, :節(jié)點(diǎn)名稱條件),
                 e.處理動(dòng)作) > 0

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 泊头市| 重庆市| 东光县| 靖江市| 云南省| 遂昌县| 九龙坡区| 正安县| 濉溪县| 攀枝花市| 平江县| 襄汾县| 盐源县| 万宁市| 定襄县| 宁明县| 鄂托克前旗| 张家川| 潮安县| 侯马市| 都兰县| 塘沽区| 尤溪县| 台前县| 浦城县| 镇雄县| 临洮县| 镇远县| 龙门县| 南靖县| 宁津县| 鸡西市| 临夏县| 泗水县| 宝山区| 视频| 霞浦县| 通化市| 神农架林区| 五寨县| 海安县|