/* 按個人需要定義,我定義三個參數(shù) ,因我項目程序需要,所以三個參數(shù)都是number ,當然可定義其它類型
但切記,第二個create 的參數(shù)類型等需以第一個create一致,否則程序包創(chuàng)建失敗
*/
create or replace package p_view_param is
--參數(shù)一
function set_param(num number) return number;
function get_param return number;
--參數(shù)二
function set_Type(num number) return number;
function get_Type return number;
--參數(shù)三
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 后面跟參數(shù),可自己拼裝,注意視圖字段要和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(); --參數(shù)
--使用視圖,傳參
select * from abstract_sum_view where p_view_param.set_id(3)=3 ;
以上就是本文關(guān)于Oracle創(chuàng)建帶有參數(shù)的視圖代碼介紹的全部內(nèi)容,希望對大家有所幫助。歡迎感興趣的朋友瀏覽本站其他相關(guān)專題,謝謝大家對腳本之家的支持!