Create a view with parameters in Oracle

Source: Internet
Author: User

Creating a view with parameters in Oracle is in Oracle. Unlike stored procedures and functions, a view can define input parameters. However, you can change the mode by using a package to define the package first: /* as defined by personal needs, I define three parameters. Because the project requires them, all three parameters are numbers. Of course, other types can be defined. But remember, the parameter types of the second create statement must be consistent with those of the first create statement. Otherwise, the package creation fails */create or replace package p_view_param is -- parameter 1 function set_param (num number) return number; function get_param return number; -- parameter 2 function set_Type (num number) return number; function get_Type return number; -- parameter 3 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 p_view_param, you can assemble it yourself. Note that the VIEW field must match the select field */create or replace view into act_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 (); -- parameter -- use view, Pass Parameter select * from parameter act_sum_view where p_view_param.set_id (3) = 3; OK finished

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.