简体   繁体   English

Oracle存储过程进入视图

[英]Oracle Stored Procedure into a View

I have a SP in oracle wich returns a cursor, before I had a query to create a viewn, but due to the complexity of the data I need, the better option to get it was a SP, but I strictly need the view with the information ( client's requirement), but now I have no idea how to put/convert the data (cursor) in the view, I was checking Global Temporary Tables, but that means I need to call the SP before accessing the view, and that's not possible. 我在oracle中有一个SP,在我有一个查询来创建viewn之前,它返回一个游标,但是由于我需要的数据的复杂性,获得它的更好的选择是一个SP,但是我严格要求使用信息(客户的要求),但是现在我不知道如何在视图中放置/转换数据(游标),我正在检查“全局临时表”,但这意味着我需要在访问视图之前调用SP,但这不是可能。 It's imperative that I call access the view with a select, Select * from view_data_sp, and obviously that the performance is not affected. 至关重要的是,我需要使用select调用access视图,从view_data_sp中选择Select *,显然性能不会受到影响。

Any idea how can I achieve this? 知道我该如何实现吗?

Thanks 谢谢

Consider using record type, table of records and pipe rows. 考虑使用记录类型,记录表和管道行。 Something like this would do the trick? 这样的事情会成功吗?

CREATE OR REPLACE package sysop as
  type file_list_rec is record(filename varchar2(1024));
  type file_list is table of file_list_rec;

  function ls(v_directory varchar2) return file_list pipelined;
end;
/

CREATE OR REPLACE package body sysop as
  function ls(v_directory varchar2) return file_list pipelined is
    rec file_list_rec;
    v_host_list varchar2(32000) := '';
  begin
    v_host_list := host_list(v_directory);

    for file in (
      select regexp_substr(v_host_list, '[^'||chr(10)||']+', 1, level)
        from dual
          connect by
            regexp_substr(v_host_list, '[^'||chr(10)||']+', 1, level) is not null)
      loop
        pipe row (file);
      end loop;
     return;
  end ls;
end sysop;
/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM