简体   繁体   English

流水线函数的结果,总是会归类为“书面”,还是不?

[英]Result from pipelined function, always will sorted as “written”, or not?

Needed get renumbered result set, for example: 需要获取重新编号的结果集,例如:

  CREATE OR REPLACE TYPE nums_list IS TABLE OF NUMBER;

  CREATE OR REPLACE FUNCTION generate_series(from_n INTEGER, to_n INTEGER, cycle_max INTEGER)
  RETURN nums_list PIPELINED AS  
      cycle_iteration INTEGER := from_n;
  BEGIN
      FOR i IN from_n..to_n LOOP
          PIPE ROW( cycle_iteration );
          cycle_iteration := cycle_iteration + 1;
          IF cycle_iteration > cycle_max THEN
             cycle_iteration := from_n;
          END IF;
        END LOOP;
        RETURN; 
  END;

  SELECT * FROM TABLE(generate_series(1,10,3));

Question is: there is guarantee, that oracle always will return result in that order? 问题是:有保证,oracle总是会按该顺序返回结果吗? :

1 2 3 1 2 3 1 2 3 1

or maybe sometimes result will unexpected ordered, like this: 或有时结果会意外地排序,如下所示:

1 1 1 1 2 2 ....

?

Pipelining negates the need to build huge collections by piping rows out of the function as they are created, saving memory and allowing subsequent processing to start before all the rows are generated 管道消除了通过在创建函数时将行从函数中移出来构建大型集合的需要 ,从而节省了内存并允许在生成所有行之前开始后续处理

pipelined-table-functions 流水线表功能

This means, it will start processing the rows before get fetched completely and that's why you are seeing unpredictable order. 这意味着,它将在完全获取之前开始处理行,这就是为什么看到不可预测的顺序的原因。

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

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