目前,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();
Java代码 收藏代码
PL/SQL调用:
<pre name="code" class="js"> select * from p_view_user where p_view_param.set_param(2781)=2781
<pre name="code" class="java"> </pre></pre>
分享到:
oracle 带参视图
猜你喜欢
转载自yhq1212.iteye.com/blog/1709279
今日推荐
周排行