Oracle 多参数查询语句

浏览: 63 发布日期: 2016-12-14 分类: oracle

废话不多说了,直接给大家贴代码了,具体代码如下所示:

CREATE OR REPLACE FUNCTION f_get_param( 
      IN_PARAM IN VARCHAR2, 
      IN_FLAG IN VARCHAR2) 
RETURN VARCHAR2 IS 
RESULT VARCHAR2(500); 
v_leng NUMBER; 
v_left NUMBER; 
v_right NUMBER; 
v_param VARCHAR2(200); 
v_param1 VARCHAR2(200); 
BEGION 
 RESULT := ''; 
 v_param:=IN_PARAM; 
 v_leng := LENGTH(v_param); 
 v_left := instr(v_param,in_flag); 
 IF v_left > 0 THEN 
  v_param1 := substr(v_param,v_left,v_leng - v_left +1) 
  v_left := instr(v_param1,':') + 1; 
  v_right := indtr(v_param1,'$'); 
  RESULT := substr(v_param1,v_left,v_right-v_left) 
 END IF; 
 RETURN(RESULT); 
 EXCEPTION 
  WHEN OTHERS THEN 
  RETURN ''; 
END f_get_param; 
//数据库赋值格式 
f_get_param(v_param,'materialtype:');//器件编码类型 
//数据库展示 
public string BuildToParams(ListArgs Args) 
{ 
  string params = '$'; 
  if(Args != null) 
  { 
    if(!string.isNotEmpty(Args.MaterailType)) 
    { 
      params = params + 'materialtypes:' + Args.MaterailType + '$'; 
    } 
  } 
  return params; 
} 
//Oracle 数据库拓展-多选参数 
SELECT instr(',' || '1,2,3,21' || ',',',' || '1' || ',') FROM DUAL 
SELECT * FROM table_name where instr(',' || list_id || ',',',' || id || ',') > 0 
//Oarcle 多条件','隔开查询  
select distinct regexp_substr('我爱你','[^.]+',1,rownum) xyz_name From dual 
connect by rownum <= length('我爱你') - length(replace('我爱你',',')) + 1 

以上所述是小编给大家介绍的Oracle 多参数查询语句,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!

返回顶部