简体   繁体   English

如何在Oracle中使用Function / s

[英]How is Function/s used in Oracle

I have Schema 我有架构

It has Tables, Views, Synonyms, Procedures and Functions. 它有表,视图,同义词,过程和函数。

I have a query it is selecting things from this functions and I don't know how it is doing that. 我有一个查询它是从这个函数中选择的东西,我不知道它是如何做到的。

Can someone help me please 有人能帮助我吗

Query is very complex but here is simple version of query. 查询非常复杂,但这里是查询的简单版本。 it is selecting something from View and Some from Function. 它从View中选择一些东西,从Function中选择一些东西。

Select 
       d.test1,
       d.test2,
       d.test3,
       d.test4,
       f.test4,
       f.test5
from TABLE(some_FN_currentevents(
      ?orgkey::0?,
      ?assettypekey::0?,
      ?nonflag?::null?,
      ?disflsg?::null?,
      ?devflag?:null?,
      ?wrkflag?:nmull?
)) t
 JOIN some_vw_fact_det d on t.intval = d.test4
 join so_vw_flat_dim f on d.test9 = f.orgkey 

just fyi 只是fyi
some_FN_currentevents is in functions in schema. some_FN_currentevents在schema中的函数中。
some_vw_fact_det is in view in schema. some_vw_fact_det在架构中处于视图中。
so_vw_flat_dim is also view in schema. so_vw_flat_dim也是模式中的视图。
I just need some example on how function and view is used in here or your own example. 我只需要一些关于如何在这里或你自己的例子中使用函数和视图的例子。

replace this: 替换这个:

TABLE(some_FN_currentevents(
      ?orgkey::0?,
      ?assettypekey::0?,
      ?nonflag?::null?,
      ?disflsg?::null?,
      ?devflag?:null?,
      ?wrkflag?:nmull?
)) t

for this one 对于这个

TABLE(select some_FN_currentevents(
      ?orgkey::0?,
      ?assettypekey::0?,
      ?nonflag?::null?,
      ?disflsg?::null?,
      ?devflag?:null?,
      ?wrkflag?:nmull?
) from dual) t

this modify works if your function return an oracle table type, if this function doesn't return an type is not posible make this query works. 如果你的函数返回一个oracle表类型,如果这个函数没有返回一个类型是不可能使这个查询工作,这个修改工作。

I'm not entirely sure what the question here is but I will write something about how to make a function return a table. 我不完全确定这里的问题是什么,但我会写一些关于如何使函数返回表的东西。

It is possible in Oracle to write a PIPELINED function that will return a TABLE . 在Oracle中可以编写一个返回TABLEPIPELINED函数。 There are several simple steps ot making this work: 有几个简单的步骤使这项工作:

  1. Create a TABLE data type. 创建TABLE数据类型。
  2. Create a PIPELINED function that returns the table data type that you have created 创建一个PIPELINED函数,该函数返回您创建的表数据类型
  3. Inside the function call PIPE ROW(x); 函数内部调用PIPE ROW(x); to add rows to the table that is going to be returned. 向要添加的表中添加行。
  4. Call the function in a SQL statement of the form SELECT * from TABLE(my_function(params)); SELECT * from TABLE(my_function(params));形式的SQL语句中调用该函数SELECT * from TABLE(my_function(params));

If you are looking for some documentation, have a look at the Oracle documentation on the subject , ort have a look at this AskTom page . 如果您正在寻找一些文档,请查看有关该主题Oracle文档 ,或者查看此AskTom页面

If this doesn't answer the question, may you could edit the question to make it a little more clear what you are asking. 如果这不能回答问题,您是否可以编辑问题以使其更清楚您的要求。

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

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