简体   繁体   中英

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.

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
some_FN_currentevents is in functions in schema.
some_vw_fact_det is in view in schema.
so_vw_flat_dim is also view in schema.
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.

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 . There are several simple steps ot making this work:

  1. Create a TABLE data type.
  2. Create a PIPELINED function that returns the table data type that you have created
  3. Inside the function call 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));

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 .

If this doesn't answer the question, may you could edit the question to make it a little more clear what you are asking.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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