java - Find a string in a specific table -
i'm working oracle database, i'm wondering if there way find rows contains value in column. example let's consider table:
weather city state high low phoenix arizona 105 90 tucson arizona 101 92 flagstaff arizona 88 69 san diego california 77 60 albuquerque new mexico 80 72
basically (i know it's not possible), this:
select * weather * '%f%'
and give me rows
flagstaff arizona 88 69 san diego california 77 60
i on java side, querying rows resultset dynamically search given value in column , add row. problem table contains millions of rows , guess more efficient on database side, fetch wanted rows network.
is possible on sql side directly?
you can use view all_tab_columns
search columns in given table:
declare v_table_name varchar2(30) := 'dual'; v_search_string varchar2(100) := 'x'; v_sql varchar2(4000); c_result sys_refcursor; begin v_sql := 'select * ' || v_table_name || ' 1=1'; r_c in (select column_name all_tab_columns table_name = v_table_name) loop v_sql := v_sql || ' or ' || r_c.column_name || ' ''%' || v_search_string || '%'''; end loop; open c_result v_sql; end; /
in case can write procedure , return cursor java fetch data.
only - time face table full scans. if @ data transfer solution better search in java.
Comments
Post a Comment