简体   繁体   English

带有缓存的Oracle流水线功能

[英]Oracle pipelined function with cache

How can use oracle pipelined function on query to fetch data only first time. 如何在查询中使用oracle pipelined函数才能第一次获取数据。

example: 例:

create or replace function best_employees return my_type pipelined;

select * from employees a 
join table(best_employees) b 
on a.employee_id = b.employee_id;

this query is calling best_employees function more than one time. 这个查询多次调用best_employees函数。 It must call only first time. 它必须只是第一次打电话。 How can i do this. 我怎样才能做到这一点。 Thanks. 谢谢。

While you could store the results in a package collection of type my_type and write the function to return that if it contained values instead of re-executing the query, the simpler and more reliable approach would be to use the result_cache hint in its query. 虽然您可以将结果存储在my_type类型的包集合中,但是如果函数包含值而不是重新执行查询,则将函数写入返回,更简单,更可靠的方法是在查询中使用result_cache提示。

select /*+ result_cache */ kitten_id, cuteness from kittens where colour = 'BLACK';

(There is also a result_cache option for functions but it cannot be used for pipelined functions.) 函数还有一个result_cache选项,但它不能用于流水线函数。)

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

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