sql条件为空查询全部,不为空按条件查询以及多条件筛选查询。

procedure queryLackLonOrLatTdCell(i_region_name varchar2, i_state varchar2) is
begin
  select region_name, state
    from gc3_td_site_history
   where 1 = 1
     and region_name =
         decode(i_region_name, null, region_name, i_region_name)
     and instr(decode(i_state, null, state, i_state), state) > 0;
end;

如果i_region_name为null,则查询出所有的region_name;否则按i_region_name查询。

如果i_state为null,则查询所有的state;如果i_state为“state1,state2”,相当于state in(state1,state2);

posted @ 2015-06-19 13:43  DurantSimpson  Views(4438)  Comments(0Edit  收藏  举报