前面创建这个带参视图转:https://www.cnblogs.com/nuaaydh/p/4342721.html(大虎1)
1.1 简介
视图不能直接带参数,要靠过程包带入参数,
1.2 带参数视图
1.2.1 先创建包
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; end p_view_param;
1.2.2 后包的实现
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; end p_view_param;
1.2.3 视图
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_Type(); --参数 --使用视图,传参 select * from abstract_sum_view where p_view_param.set_Type(3)=3 ;
1.3 Dblink创建
https://www.cnblogs.com/daguozb/p/10309873.html
就是查询有点区别,假设创建的dblink名称为testDblink:
select * from abstract_sum_view@testDblink where p_view_param.set_Type@testDblink (3)=3 ;
这样就可以了。
那个包的赋权需要赋execute;
GRANT execute ON "TESTUSER"." P_VIEW_PARAM" TO GALEN;