Can pipelined functions' return values be used in WHERE clause?

If I have function MY_FUNC that returns a REFCURSOR with columns COL1, COL2, COL3
can I use the values returned in the output cursor in my WHERE clause as well as in the SELECT clause?
e.g.
SELECT COL1, COL2, COL3
FROM TABLE(MY_FUNC(param1, param2))
WHERE COL1 = 24 AND COL2=25
Would that be proper SQL?

Hi,
SQL> Create OR Replace Package Pkg_Test_ Is
  2 
  3     Type my_typ Is Table Of Number;
  4 
  5     Function fnc_test Return my_typ Pipelined;
  6 
  7  End;
  8  /
Package created
SQL> Create OR Replace Package Body Pkg_Test_ Is
  2 
  3     Function fnc_test Return my_typ
  4        Pipelined Is
  5        va_typ my_typ := my_typ();
  6     Begin
  7        For i IN 1 .. 10 Loop
  8           va_typ.Extend;
  9           va_typ(va_typ.Count) := i;
10           Pipe Row(va_typ(va_typ.Count));
11        End Loop;
12        Return;
13     End;
14 
15  End;
16  /
Package body created
SQL> SELECT *
  2    FROM Table(PKG_TEST_.FNC_TEST)
  3   WHERE COLUMN_VALUE > 5
  4  /
COLUMN_VALUE
           6
           7
           8
           9
          10Regards,
Christian Balz

Similar Messages

  • Can oracle  function return more than one value

    Hi All
    please answer can oracle function return more than one value
    need one schenario
    regards

    Can any function, irrespective of the language, return multiple values?
    OF COURSE NOT!!
    So why do you think Oracle will now suddenly do it differently than all other languages? Never mind that it is impossible for a function (a unit/module of code) returning a memory address, to return multiple memory addresses. The machine code that does that, has not been yet been designed/implemented.
    I am continually amazed that this question is asked. It is about something so fundamental in almost every single 3rd and 4th generation language... something that is taught right at the start... the definition of what a procedure and what a function is.
    Sorry, but I simply cannot pull punches on this subject and smooth it over. There is something fundamentally wrong with your training as a programmer if you have to ask such a question about a function.
    And whatever programming skills you build on such a foundation, will be seriously lacking.
    I kindly suggest that you get back to the very basics of programming - and review and revisit until you fully understand it. There are no shortcuts in becomming a good programmer.
    Message was edited by:
    Billy Verreynne

  • Can a function return two values???

    Hi guys can a function return more than values?

    Or even better return an Object.
    ie
    public class Tester{
         public static Multi getM()
              Multi m=new Multi();
              m.x="testing";
              m.y="new value";
         public static void main(String [] args)
              Multi mt=getM();
              System.out.println(mt.x);
              System.out.println(mt.y);
         class Multi{
              public String x;
              public String y;
    }

  • Unable to see function return values in Visual Studio 2013 debugger

    Hi!
    I can't see function return values in
    Microsoft Visual Studio Ultimate 2013
    Version 12.0.31101.00 Update 4
    Microsoft .NET Framework
    Version 4.5.51650
    Installed Version: Ultimate<o:p></o:p>
    as described in  http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/27/seeing-function-return-values-in-the-debugger-in-visual-studio-2013.aspx
    So what can I do to get this functionality back?
    MsdnMezzo

    Hi MsdnMezzo,
    Reference:
    http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/27/seeing-function-return-values-in-the-debugger-in-visual-studio-2013.aspx
    If use the same sample in the above blog provided by you, how about the result? Could you debug it with the same steps? I could debug it in my side using the VS2013.
    So to make sure that whether it is your VS IDE issue, please debug it with this sample, if it works well, I doubt that we would think about your specific project and the debugging steps.
    If so, to really repro this issue, could you share us a sample with one drive? You could upload your project to one drive and share us the downloaded link in your new reply, I will download and repro this issue in my side.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    I want to call Stored Procedure that return records and output parameter, from CVI
    I can get output parrameter but when I want to get records stream I recieve following wrror:
    function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    in Stored procedure I create table variable and and insert into string values
    when I remove usage of table variable the error desappear

  • How can a function return a constant reference to an object

    how can a function return a constant reference to an object so that the calling party dont have rights to change it.
    like this example
    class obj = somefunc();
    obj.changeit(); // this line lust give error saying that its read only..
    somefunc()
    return criticalobj;
    in c++ we can achieve this by using the const pointer to the object.. how can we do this in java???

    arun160411 wrote:
    in c++ we can achieve this by using the const pointer to the object.. how can we do this in java???Of course the first thing anyone learns about const pointers is how to cast away constness, so this is completely useless, up there with the chastity movement's thong underwear with the stop sign on it. If you can read this, you're too close!

  • Just converted word to PDF so that I can save on iPhone and subsequently use. Where is the file??

    Just converted word to PDF so that I can save on iPhone and subsequently use. Where is the file?? I have no idea where it is!! Extremely frustrating and not at all user friendly!! Took my 6.99 British pounds and not a sausage to be had!!

    It sounds like you may have purchased a CreatePDF subscription through safari, using our web interface. If this is the case, the good news is that subscription will also work with the (free) Adobe Reader. Simply install the Reader from the App Store:
    https://itunes.apple.com/us/app/adobe-reader/id469337564?mt=8
    Once installed, you can then use "Open In" from another app like Mail to open the Word document in Adobe Reader. Reader will show the word doc, but it will also show you a message pointing to the "convert" button (A document with an arrow through it in the toolbar). Pressing this button should prompt you to sign into Acrobat.com. Use the same account you used to purchase your subscription and Reader will upload the word document for conversion, placing it in the Acrobat.com and Outbox section of the Reader. Please let me know if you have trouble!

  • Trying to use a where clause from a table

    hi,
    I have a report and I need to use a where clause that is archived in a table, it is a different one depending on the row (colour=blue or number = 88..) I have tryied with ref cursor, dinamis sql, functions, packages and could not get it, any suggestion??
    thanks

    You may use Lexical Rerefences: "Lexical references are placeholders for text that you embed in a SELECT statement. You can use lexical references to replace the clauses appearing after SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, CONNECT BY, and START WITH....."

  • What happens u0093Updateu0094 command is used without where clause ?

    Hi
    What happens “Update” command is used without where clause ? 
    thank you

    Hi subash,
    chk this help
    UPDATE  dbtab      SET f1 ... fn. or
    UPDATE (dbtabname) SET f1 ... fn.
    Extras:
    1. ... WHERE condition
    2. ... CLIENT SPECIFIED
    3. ... CONNECTION con
    Effect
    Updates values in a database table. <b>If there is no WHERE clause, all lines (in the current client) are updated.</b> If a WHERE condition is specified, only thoserecords which satisfy the WHERE condition are updated.

  • How do you use 3 Where Clauses in a query

    Hi, i am trying to figure out how to use 3 Where Clauses in a Query where 2 of the Where Clauses uses a Sub query.
    Display the OrderID of all orders that where placed after all orders placed by “Bottom-Dollar Markets”.
    Order the result by OrderID in ascending order.
    First WHERE clause checks for OrderDate and uses a sub query with ALL keyword.
    Second WHERE clause use equals and sub query.
    Third WHERE clause uses equal and company name.
    This is what i have so far but i am pretty confused on how to do this.
    My Code for NorthWind:
    Select OrderID
    From Orders o
    Where o.OrderID IN (Select OrderDate From Orders Where Orders.OrderID > ALL
    (Select CompanyName From Customers Where CompanyName = 'Bottom-Dollar Markets'));
    The book shows how to use the ALL Keyword but not in a Sub query with Multiple Where Clauses.
    Select VenderName, InvoiceNumber, InvoiceTotal
    FROM Invoices JOIN Vendors ON Invoices.VendorID = Vendors.VendorID
    WHERE InvoiceTotal > ALL (Select InvoiceTotal From Invoices Where VendorID = 34)
    ORDER BY VendorName;

    >Where Orders.OrderDate
    > ALL  (Select
    CompanyName
    The comparison operator (>) requires compatible data types.
    DATETIME is not compatible with VARCHAR string for comparison.
    Here is your homework:
    SELECT orderid
    FROM orders o
    WHERE o.orderdate > ALL (SELECT orderdate
    FROM orders
    WHERE shipvia = (SELECT Max(shipvia)
    FROM orders o
    INNER JOIN customers c
    ON c.customerid =
    o.customerid
    WHERE
    c.companyname = 'Bottom-Dollar Markets'));
    11064
    11065
    11066
    11067
    11068
    11069
    11070
    11071
    11072
    11073
    11074
    11075
    11076
    11077
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • How can i pass function return values in to varray

    Hi
    create procedure name(parameters list)
    here ---i am calling a function
    varname := function name
    returns 4 values
    My doudt is how can i pass these return values in to varray..
    Type varray vname[5] date type
    Begin
    statements
    end prodedure name;
    pls clarify me its urgent

    This may give u a start
    sql>
    create or replace package test_array_pack as
    type ar1 is varray(10) of number;
    end;
    Package created.
    sql>
    create or replace function test_array return test_array_pack.ar1 is
      v_ar1 test_array_pack.ar1;
    begin
    v_ar1 := test_array_pack.ar1(1,2,3,4);
    return v_ar1;
    end;
    Function created.
    sql>
    declare
    v_ar2 test_array_pack.ar1;
    begin
    v_ar2 := test_array;
    end;
    PL/SQL procedure successfully completed
    Message was edited by:
            jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Group by on Function return value

    Dear All
    I'm facing a problem with when I have a group by on the return value of a function.
    Following is the scenario.
    Im having the following select query which executes in less than millisec for more than 20k records.
    SELECT T1.FIELD1,T1.FIELD2, MY_FUNCTION(T1.FIELD2) FROM TABLE T1 ;
    But when I modify the above query in the following way for the same number of records, the performance is going down to more than 4 mts.
    SELECT T1.FIELD1,T1.FIELD2, MY_FUNCTION(T1.FIELD2)FIELD3 FROM TABLE T1 GROUP BY T1.FIELD1,T1.FIELD3;
    can any one please suggest me whats the best solution in this regard.
    Thanks in advance
    Narayanan

    SQL> create or replace function get_sub(a varchar2)
      2  return varchar2
      3  is
      4  begin
      5   return substr(a,1,1);
      6  end;
      7  /
    Function created.
    SQL> select deptno, get_sub(ename) sub from emp;
        DEPTNO S
            20 S
            30 A
            30 W
            20 J
            30 M
            30 B
            10 C
            20 S
            10 K
            30 T
            20 A
            30 J
            20 F
            10 M
    14 rows selected.
    SQL> select deptno, get_sub(ename) sub, count(1)
      2  from emp
      3  group by deptno, get_sub(ename)
      4  /
        DEPTNO S   COUNT(1)
            10 C          1
            10 K          1
            10 M          1
            20 A          1
            20 F          1
            20 J          1
            20 S          2
            30 A          1
            30 B          1
            30 J          1
            30 M          1
            30 T          1
            30 W          1
    13 rows selected.Rgds.
    Everything which is not affected by aggregate functions
    should be included into GROUP BY. And GROUP BY can't use
    aliases but expressions only.
    You have to think what exactly do you want to get
    for FIELD02 - do you want get max/min/avg/count ?
    Message was edited by:
    dnikiforov
    (I'm asking because your query probably should look like
    SELECT T1.FIELD1,T1.FIELD2, MY_FUNCTION(T1.FIELD2) FIELD3 FROM TABLE T1 GROUP BY T1.FIELD1,T1.FIELD2
    Message was edited by:
    dnikiforov

  • Can Evaluate function return object type

    Hi
    Evaluate function can be used to call db functions in OBIEE. I have a function which returns an object ( pl/sql table).
    Created a simple report in Oracle Answers and added following in one of the columns
    evaluate( 'get_ccid(%1)' as t_ccid , @{p_request})
    When I try to run this in Oracle answers, getting syntax error. If same function returns varchar or number it works well.

    evaluate( 'get_ccid(%1)' as t_ccid , @{p_request})Eakta, You syntax seems to be wrong here. What type of data your presentation variable contains here ?? You are saying its working fine with Number datatype..so can you try..somthing like below with some default value..
    EVALUATE('get_ccid(%1)',@{p_request}{2})
    OR
    EVALUATE('get_ccid(%1)' as varchar(250),@{p_request}{ABC})
    Also, refer
    Syntax for Evaluate function in OBIEE
    http://108obiee.blogspot.com/2009/04/using-presentation-variable-from-first.html
    Hope its useful

  • ExtendScript function return values

    As far as I can tell, it's only possible to run ExtendScript functions from a CS Extension. I don't see any (straight-forward) way get the return value of an ExtendScript function.
    CSXSInterface.getInstance().evalScript() does not seem to return any useful information. Am I missing something, or should I make a feature request?
    Harbs

    I must be doing something wrong, because it's still not working...
    Here's my ExtendScript:
    function test1(){
    alert(1);
    return "bla bla";
    function test2(){
    alert(2);
        return{
            text:"bla bla",
            number:1
    function test3(){
    alert(3);
        return
            <bla>
                <ble/>
                <ble>
                    <blu/>
                </ble>
            </bla>
    Here's my ActionScript:
                var result1:SyncRequestResult = CSXSInterface.getInstance().evalScript("test1");
                var result2:SyncRequestResult = CSXSInterface.getInstance().evalScript("test2");
                var result3:SyncRequestResult = CSXSInterface.getInstance().evalScript("test3");
    and here's what I'm seeing in the debugger:
    I am getting all three alerts, so I know that the functions are being run...
    Harbs

  • FDM Lookup function returning value not = the current POV

    Is anyone having problems returning values for periods other than current POV.
    "The FDM Lookup function is used to return the value of any source account that resides in FDM.
    The function can be used within a logic function or a logic expression."
    Presently I can only return value in current POV.
    If anyone can return a source account value from a period other than the current POV let me know.
    Tom Peera
    Syntax
    | , , 02/28/2011 , 1535-000-000 |

    Here is the dirty fix, I'm heading off to sleep.
    If the function CurrentAdId doesn't return a number, then
    this will ensure it returns 0 (prevents your error, may not display
    an ad):
    <CFFUNCTION
    NAME="CurrentAdId"
    ACCESS="Private"
    RETURNTYPE="numeric"
    HINT="For internal use. Returns the Id of the current ad in
    rotation.">
    <!--- Return the adId from the current row of the
    GetAdIds query --->
    <cfset var returnVal = ListGetAt(THIS.AdList,
    THIS.CurrentListPos)>
    <cfif NOT IsNumeric(returnVal)>
    <cfset returnVal = 0>
    </cfif>
    <CFRETURN returnVal>
    </CFFUNCTION>

Maybe you are looking for