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

文章作者 100test 发表时间 2007:09:25 12:53:29
来源 100Test.Com百考试题网


系统中遇到了要处理多条件组合查询的情况,使用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).


相关文章


将ORACLE数据库的数据倒入到EXCEL中的方法
使用Oracle的I tr()与decode()函数进行多条件组合查询
如何查看unix下某个oracleOS的进程在做什么操作
如何在hp-ux10.20系统中正确地配置oracle8.0.5
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛