如何通过函数创建oracle视图

时间:2016-12-07 04:29:49

标签: sql oracle

如何按功能创建oracle视图
 1.首先创建一个类型' p_type'
 2.创建一个表格' p_table' as' p_type'
 3.具有' p_table'的功能。管道

create or replace type p_type as object (
    v_name varchar(400),
    d_date date,
    i_val number 
);

create or replace type p_table as table of p_type;

create or replace function get_info return p_table pipelined 
is
    c number;
begin
    c := 1;
    /*
        A is table and it has only one 'a' attribute
    */
    for i in (select * from A) loop
        pipe row( p_type(
                    v_name => SUBSTR(i.A, 1, 10),
                    d_date => sysdate,
                    i_val  => c
            ) );
        c := c + 1;
    end loop;
    return;
end;


CREATE VIEW vw_info AS 
    select * from table(get_info);

0 个答案:

没有答案