/* 按个人需要定义,我定义三个参数 ,因我项目程序需要,所以三个参数都是number ,当然可定义其它类型
但切记,第二个create 的参数类型等需以第一个create一致,否则程序包创建失败
*/
create or replace package p_view_param is
--参数一
function set_param(num number) return number;
function get_param return number;
--参数二
function set_Type(num number) return number;
function get_Type return number;
--参数三
function set_Id(num number) return number;
function get_Id return number;
end p_view_param;
--
create or replace package body p_view_param is
paramValue number;
paramType number;
paramId number;
-- Param
function set_param(num number) return number is
begin
paramValue:=num;
return num;
end;
function get_param return number is
begin
return paramValue;
end;
-- Type
function set_Type(num number) return number is
begin
paramType:=num;
return num;
end;
function get_Type return number is
begin
return paramType;
end;
-- ID
function set_Id(num number) return number is
begin
paramId:=num;
return num;
end;
function get_Id return number is
begin
return paramId;
end;
end p_view_param;
/*
*定义视图,where 后面跟参数,可自己拼装,注意视图字段要和select的字段匹配
*/
CREATE OR REPLACE VIEW abstract_sum_view(fa_id, aircraft_num,aircraft_weight,airline_code,anchor_pos)
AS SELECT f.fa_id, f.aircraft_num,findweight(f.aircraft_num),f.airline_code,f.anchor_pos
FROM tb_flight_abstract f
where f.fa_id=p_view_param.get_Id(); --参数
--使用视图,传参
select * from abstract_sum_view where p_view_param.set_id(3)=3 ;