Oracle视图 传参数 解决办法
目前,Oracle不支持带参数的视图,只能通过一些方法来变通一下。下面是方法之一:
创建包:
create or replace package p_view_param is
function set_param(num number) return number;
function get_param return number;
end p_view_param;
create or replace package body p_view_param is
paramValue number;
function set_param(num number) return number is
begin
paramValue:=num;
return num;
end;
function get_param return number is
begin
return paramValue;
end;
end p_view_param;
视图的建立:
create or replace view p_view_user as
select id,realName,address from tbl_info where id=p_view_param.get_param();
PL/SQL调用:
select * from p_view_user where p_view_param.set_param(2781)=2781