plsql存储过程中,将字段名作为参数,急!
存储过程如下:
create or replace procedure userstest(v_string,v_column in varchar2, v_cursor out sys_refcursor)
is
begin
if(v_column ='name') then
open v_cursor for select * from users where name=v_string;
elsif (v_column='password') then
open v_cursor for select * from users where name=v_string;
end if;
end;
这里的问题是,没有将where后面的字段名作为参数传过去,而是将字段名做了判断,这样写的话,如果有n个字段的话,就要写n个判断,拜托各位帮忙看看,能不能直接将v_column传给where后面的字段名,就不需要用if判断了,并且能用游标打开。很急,求大佬助攻!