Please, help us i want to fetch more than one returns of rows while searching a data from table.Here in this code. if only one row matches the condition given then it returns the output,else where it shows an error when multiple rows matches the condition.
create or replace procedure bank_search_test1
(
p_tablename in char,
p_searchname in char,
p_bankcode out char,
p_bankname out char,
p_distcode out number
)
as
v_tem varchar2(500);
begin
v_tem := 'select bankcode,bankname,dist_code from ' || p_tablename || ' where bankcode like ''%' ||
p_searchname || '%''';
execute immediate v_tem into p_bankcode, p_bankname,p_distcode;
end;
This is the error shown when multiple rows matches
Running "PENSIONS"."BANK_SEARCH_TEST1" ( P_TABLENAME = bank, P_SEARCHNAME = D ).
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "PENSIONS.BANK_SEARCH_TEST1", line 13
ORA-06512: at line 1