In Oracle, unlike stored procedures and functions, views can define input parameters, but we can change the way and use packages to implement them.
oracle package:
The oracle package is an oracle package, which is a combination of PL/SQL programming elements such as a set of related procedures, functions, variables, constants, types, and cursors. The package has the characteristics of object-oriented design, and it is the encapsulation of these PL/SQL programming elements.
The role of Oracle's Package:
Simplify application design, improve application performance, implement information hiding, and subroutine overloading.
What is the difference between packageand package body?
Package is the definition of each method, and package body is the specific implementation. These two are integrated and must exist at the same time.
1. First define the package:
create or replace package p_view_param_test is
--参数一
function set_baseid(val varchar2) return varchar2;
function get_baseid return varchar2;
--参数二
function set_date(val number ) return number;
function get_date return number;
end p_view_param_test;
create or replace package body p_view_param_test is
paramValue varchar2(100);
paramValue1 number;
-- baseid
function set_baseid(val varchar2) return varchar2 is
begin
paramValue:=val;
return val;
end;
function get_baseid return varchar2 is
begin
return paramValue;
end;
-- basecreatedate
function set_date(val number) return number is
begin
paramValue1:=val;
return val;
end;
function get_date return number is
begin
return paramValue1;
end;
end p_view_param_test;
Two, create a view
CREATE OR REPLACE VIEW view_test as
select * from test where baseid =p_view_param_test.get_baseid() and basecreatedate =p_view_param_test.get_date();
Three, sql call
select * from view_test where p_view_param_test.set_baseid('055e5b14-e8e5-4be7-9823-4976daa5902f')='055e5b14-e8e5-4be7-9823-4976daa5902f'
and p_view_param_test.set_date(1473423713)=1473423713;