creating parameterized views in oracle11g

前端 未结 3 1592
Happy的楠姐
Happy的楠姐 2020-11-28 12:20

I have a big query with nesting and left join and Ineed to create a view out of it so as not to run it from the application. The issue is I need the date range and some othe

3条回答
  •  独厮守ぢ
    2020-11-28 12:39

    I have just made a workaround for this annoying Oracle disadvantage. Like this

    create or replace package pkg_utl
    as
      type test_record is record (field1 number, field2 number, ret_prm_date date);
      type test_table is table of test_record;
      function get_test_table(prm_date date) return test_table pipelined;
    end;
    /
    
    create or replace package body pkg_utl
    as
      function get_test_table(prm_date date) return test_table pipelined
      is
      begin
        for item in (
          select 1, 2, prm_date
          from dual
        ) loop
          pipe row (item);
        end loop;
        return;
      end get_test_table;
    end;
    /
    

    it still requires a package, but at least i can use it in more convinient way:

    select *
    from table(pkg_utl.get_test_table(sysdate))
    

    i am not sure about performance...

提交回复
热议问题