oracle中创建带in参数的视图 为了创建带参数的视图,在网上搜索了一下,基本可以实现,但是如果我的条件是in不是=,就搞不定了。具体做法如下:
1. 建立package
create or replace package p_view_param is
function set_param(lottype in varchar2) return varchar2;
function get_param return varchar2;
end p_view_param;
create or replace package body p_view_param is
paramValue varchar2(100);
function set_param(lottype in varchar2) return varchar2 is
begin
paramValue:=lottype;
return lottype;
end;
function get_param return varchar2 is
begin
return paramValue;
end;
end p_view_param;
2.建立view
create or replace view p_view_user as
select lotid,lottype from sdb_tB_info_wip where lottype = p_view_param.get_param();
3. 使用view
select * from p_view_user where p_view_param.set_param('LF')='LF',这样可以出来想要的结果
问题是如果把view脚本改成下面的:
create or replace view p_view_user as
select lotid,lottype from sdb_tB_info_wip where lottype in p_view_param.get_param();
运行下面语句返回的结果是('LF','L')
SELECT p_view_param.set_param('(''LF'',''L'')') FROM DUAL
但是通过访问view却没有任何结果:
select * from p_view_user where p_view_param.set_param('(''LF'',''L'')')=('LF','L')
请高手指点一下,这里应该如何操作了喃?
------解决方案--------------------
select * from p_view_user where p_view_param.set_param('(''LF'',''L'')')=('LF','L')