Querying from a cursor function

Is there any way to use a cursor function in the from clause of a query?

Hallo,
you mean probably CURSOR expression.
No, we cannot...
select * from (cursor(select * from emp))ORA-22902: CURSOR expression not allowed
Cause: CURSOR on a subquery is allowed only in the top-level SELECT list of a query.
Action: none
Regards
Dmytro

Similar Messages

  • Can the return from xsql:ref-cursor-function be saved & looped through XSQL?

    If <xsql:ref-cursor-function> returns one field for a number of rows, is there a way to save those values and loop through the data retrieved for other query process within XSQL? Any example?
    Thanks.
    null

    You have a couple of options.
    You can process the XML returned by <Xsql:ref-cursor-function> as the normal part of XSLT processing, or you can write a custom action handler that aggregates the action handler for <xsql:ref-cursor-function> and then uses DOM to operate on the return value.
    Search the Online XSQL Pages Documentation for the term "MyIncludeXSQLHandler" for some sample code that illustrates building a customer action handler that aggregates one of the built-in handlers.

  • How to create a Type Object with Dynamic select query columns in a Function

    Hi Every One,
    I'm trying to figure out how to write a piplined function that executes a dynamic select query and construct a Type Object in order to assigned it to the pipe row.
    I have tried by
    SELECT a.DB_QUERY INTO actual_query FROM mytable a WHERE a.country_code = 'US';
    c :=DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(c,actual_query,DBMS_SQL.NATIVE);
    l_status := DBMS_SQL.EXECUTE(c);
    DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
    FOR j in 1..col_cnt LOOP
    DBMS_SQL.DEFINE_COLUMN(c,j,v_val,2000);
    END LOOP;
    FOR j in 1..col_cnt LOOP
    DBMS_SQL.COLUMN_VALUE(c,j,v_val);
    END LOOP;
    But got stuck, how to iterate the values and assign to a Type Object from the cursor. Can any one guide me how to do the process.
    Thanks,
    mallikj2

    Hi Justin,
    First of thanks for your reply, and coming to my requirement, I need to report the list of items which are there in the dynamic select statement what am getting from the DB. The select statement number of columns may vary in my example for different countries the select item columns count is different. For US its '15', for UK it may be 10 ...like so, and some of the column value might be a combination or calculation part of other table columns (The select query contains more than one table in the from clause).
    In order to execute the dynamic select statement and return the result i choose to write a function which will parse the cursor for dynamic query and then iterate the values and construct a Type Object and append it to the pipe row.
    Am relatively very new for these sort of things, welcome in case of any suggestions to make it simple (Instead of the function what i thought to work with) also a sample narrating the new procedure will be appreciated.
    Thanks in Advance,
    mallikj2.

  • XSQL ERROR with bind-params in ref-cursor-function

    Hi Steve
    I always get the error
    ORA-01006 bind variable does not exist
    when using a bind variable in a <xsql:ref-cursor-function> action element.
    when I replace the bind variable with a @ - parameter substitution, all works fine.
    My configuration:
    XSQL 1.0.4.1 on Win200Pro ,Apache + Jserv + DB from ORA 8.1.7 installation
    My Source
    <xsql:ref-cursor-function
    dbconn="ekat"
    eblike="%"
    list="a0"
    bind-params="eblike"
    include-schema="no"
    null-indicator="no"
    id-attribute=""
    fetch-size="500"
    >
    {@dbconn}o.ekatkategcv.open_cv_ebh ('{@list}', :1)
    </xsql:ref-cursor-function>
    ( dbconn selects my schema, not changed often, which contains package ekatkategcv with
    function open_cv_ebh returning a cursor)
    Any fix would be appreciated to avoid reparsing on each call.
    BTW, is it right, that a ref-cursor funtion is reparsed whenever the content of
    a parameter used with @ changes?
    Best regards
    H.Buschmann ([email protected])
    null

    I have tried it using ? instead of :1, this method works fine.
    I haven't tried the name method (:bindvar) yet.
    Until now, I only used xsl:query and xsql:ref-cursor-function, so I didn't check
    the other action handlers with bind variables like :1
    null

  • Select query on REF CURSOR

    Hi all,
    I am trying see if we can use LINQ like functionality to query a ref cursor resultset. I have about 50 procedures( as part of 12 packages) which send the ref cursor output to a front end application when called individually. Now I need to create a procedure to get only specified records from each of these 50 ref cursors and output it to another ref curosr.
    In other words how can I use the following
    select col_2 from pkg_abc.pro_ref_cursor_out(arg1, arg2...) where col_1 = 'X':I am not inclined to use a fetch as I foresee performance issues?
    Thanks

    @ Tubby. Here is what I am looking to do. Let us say I have two packages as below each with one ref cursor. In reality there are about 15 packages and 50 procedures and hence 50 ref cursors.
    CREATE OR REPLACE PACKAGE pkg_1
    IS
       TYPE resultset_typ IS REF CURSOR;
       PROCEDURE pro_1 (
          i_region          IN       VARCHAR2,
          o_resultset      OUT      resultset_typ,          -- 'recordset' output
    END pkg_1;
    CREATE OR REPLACE PACKAGE BODY pkg_1
    IS
       PROCEDURE pro_1 (
          i_region          IN       VARCHAR2,
          o_resultset      OUT      resultset_typ,         
       IS
        BEGIN
           OPEN o_resultset FOR
                 SELECT 'employees' AS person_type, employee_name FROM tbl_employees WHERE region = i_region;   
        END;
       END pro_1;
    END pkg_1;
    CREATE OR REPLACE PACKAGE pkg_2
    IS
       TYPE resultset_typ IS REF CURSOR;
       PROCEDURE pro_2 (
          i_region          IN       VARCHAR2,
          o_resultset      OUT      resultset_typ,          -- 'recordset' output
    END pkg_2;
    CREATE OR REPLACE PACKAGE BODY pkg_2
    IS
       PROCEDURE pro_2 (
          i_region          IN       VARCHAR2,
          o_resultset      OUT      resultset_typ,         
       IS
        BEGIN
           OPEN o_resultset FOR
                 SELECT 'customers' AS person_type, customer_name FROM tbl_customers WHERE region = i_region;
        END;
       END pro_2;
    END pkg_2;Currenlty the front end app calls these packages individually when required. But I want to create an additional package as follows so that I dont have to write the underlying queries again.
    CREATE OR REPLACE PACKAGE pkg_3
    IS
       TYPE resultset_typ IS REF CURSOR;
       PROCEDURE pro_3 (
          i_region          IN       VARCHAR2,
          i_name           IN       VARCHAR2,
          o_resultset      OUT      resultset_typ,          -- 'recordset' output
    END pkg_3;
    CREATE OR REPLACE PACKAGE BODY pkg_3
    IS
       PROCEDURE pro_3 (
          i_region          IN       VARCHAR2,
          i_name           IN       VARCHAR2,
          o_resultset     OUT      resultset_typ,         
       IS
        BEGIN
           OPEN o_resultset FOR
                 SELECT * FROM pkg_1.pro_1(i_region) WHERE employee_name = i_name
                 UNION ALL
                 SELECT * FROM pkg_2.pro_2(i_region) WHERE customer_name = i_name
        END;
       END pro_3;
    END pkg_3;

  • How to use cursor function for nested xml

    Hi,
    i have a query for XMLQuery like
    select * from bills where bill_id=????
    it results in something like
    <bills>
    <bill>
    <city>london</city>
    <amount>44</amount>
    </bill>
    <bill>
    <city>london</city>
    <amount>988</amount>
    </bill>
    <bill>
    <city>new york</city> <amount>59</amount> </bill>
    </bills>
    but i want xml output to be sorted for city names adding one more level location like
    <bills>
    <location city="london">
    <bill>
    <amount>44</amount>
    </bill>
    <bill>
    <amount>988</amount> </bill>
    </location>
    <location city="new york">
    <bill>
    <amount>59</amount> </bill>
    </location>
    </bills>
    it should be possible to iterate through the same table to gather informaton with the help of cursor function, but never used CURSOR before.
    any idea?

    sreese wrote:
    p_desig works as a comma delimited string without the NVL function, that's not the issue.
    It IS the issue .. you need to provide  a SAMPLE so we can see what you're doing ..
    How are you "passing it in" ?
    option A:
    procedure ( in_var  in  VARCHAR2 )
    AS
    and nvl(sn.c_attribute1,'x@#$%') in nvl(in_var,'x@#$%')
    option B:
    and nvl(sn.c_attribute1,'x@#$%') in nvl(&1,'x@#$%')
    .. or some other method?

  • Return XML from REF CURSOR

    It appears to be fairly straight-forward to get XML from a SQL query using the XML SQL Utility.
    Is it possible to use this utility (or another) to get XML from a cursor variable as well? I would like to generate overloaded get_xml functions in a PL/SQL package that will accept either SQL or a weak type REF CURSOR and return XML.

    Thanks for the help. Actually, I just bought your book and was getting ready to do some research. This should get me pointed in the right direction.
    Does the PL/SQL API lack this functionality? I wasn't sure whether to implement this in PL/SQL or Java, but the decision may be made for me...

  • Getting a ResultSet from a stored function

    Hi everybody.
    I don't know if it's possible but i would like call a stored function with JDBC, and that function returns not a single value (like a VARCHAR2 or a NUMBER) but the "equivallent of a Java ResultSet".
    With JDBC, i can execute a query like "SELECT * FROM Emp" and fetch a set of row in a ResultSet.
    Instead of preparing and executing a SQL query from my Java source, i would preferred calling a stored function.
    But i don't know which data type my function should return.
    I would like to know if such a thing is possible.
    Maybe somebody have an sample source code ...
    Thanks.

    You can get values OUT of the procedure by (lines with registerOutParameter):
    cstmt = conn.prepareCall("{call hrx_get_empl_benefit_cost(?,?,?,?,?,?,?)}");
    cstmt.setInt(1,employee.getId());
    cstmt.setInt(2,plan.getId());
    cstmt.setString(3,cvgAmtOrLevel);
    cstmt.setString(4,effDate);
    cstmt.registerOutParameter(5,Types.VARCHAR);
    cstmt.registerOutParameter(6,Types.VARCHAR);
    cstmt.registerOutParameter(7,Types.VARCHAR);
    cstmt.execute();
    I do not think it returns a resultSet like you are thinking. I guess you are talking about getting values out and not a cursor of records or several records of values.

  • How to run a sql query from a button in apex 3.0

    Hi,
    I am brand new and went through/installed the obe project tracker. I have need to create a simple application that displays a result (2 fields, name and license number) based on two parameters (dob and login id) which all are stored in 1 table in the database. I could this very simply in VB or VB.net but have no idea how to do it in apex.
    Please provide guidance,
    Thank you,
    Tom

    Hi Tom,
    Sounds like a report region will satisfy your requirements.
    Create a new report region on one of your pages.
    Choose SQL Report and give the region a title.
    When you get to the "Enter SQL Query or PL/SQL function returning a SQL Query:" step, type:
    SELECT name, license_number
    FROM   <insert_your_table_name_here>
    WHERE  dob = :P<n>_dob
    AND    login_id = :P<n>loginid(replace <n> with the page number that the region is on and use your own table name).
    Don't try to run the page yet - it will give 'No data found'
    Now, go back to the Page Definition screen and add two items in the region you just created - call them P<n>dob and P<n>login_id
    Then, create a button in the same region (to be displayed amongst the region's items) - call it P<n>_GO and click 'Create' (take all the other defaults).
    Now you can run the page, put some values into the fields and click go.
    If you want to get fancier, you can change the text items to select lists etc. - let us know if you need help with that.
    Hope this helps,
    Bryan.

  • Error - opening a web query from my favorite or roles

    I am trying to open a query saved as web query from my favorite folder or user menu. I got error when processing the request. Below is the detailed error.
    Error when processing your request
    What has happened?
    The URL http://p2pr3.ittind.com:8000/sap/bw/BEx was not called due to an error.
    Note
    The following error text was processed in the system DVR : You can only work in client 010
    The error occurred on the application server P2PR3_DVR_00 and in the work process 0 .
    The termination type was: ABORT_MESSAGE_STATE
    The ABAP call stack was:
    Function: RS_MANDT_CHECK of program SAPLRSMANDT
    Form: CLIENT_CHECK of program SAPLRSDG_IOBJ_DB_READ
    Function: RSD_IOBJ_GET_A_THEN_M of program SAPLRSDG_IOBJ_DB_READ
    Function: RSZ_X_COMPONENT_EXIST of program SAPLRZX0
    Form: GET_AUTHORIZATION of program CL_RSRD_UTILITIES_BW_OBJECTS==CP
    Form: SET_ITEM of program CL_RSRD_WWW_ITEM_BROADCASTER==CP
    Form: INIT of program CL_RSR_WWW_ITEM===============CP
    Form: CREATE of program CL_RSR_WWW_ITEM===============CP
    Form: SET_ITEM of program CL_RSR_WWW_PAGE===============CP
    Form: SET_TEMPLATE_ITEMS of program CL_RSR_WWW_ITEM_TEMPLATE======CP
    What can I do?
    If the termination type was RABAX_STATE, then you can find more information on the cause of the termination in the system DVR in transaction ST22.
    If the termination type was ABORT_MESSAGE_STATE, then you can find more information on the cause of the termination on the application server P2PR3_DVR_00 in transaction SM21.
    If the termination type was ERROR_MESSAGE_STATE, then you can search for more information in the trace file for the work process 0 in transaction ST11 on the application server P2PR3_DVR_00 . In some situations, you may also need to analyze the trace files of other work processes.
    If you do not yet have a user ID, contact your system administrator.
    Error code: ICF-IE-http -c: 035 -u: NKRISHNA -l: E -s: DVR -i: P2PR3_DVR_00 -w: 0 -d: 20081022 -t: 120849 -v: ABORT_MESSAGE_STATE -e: You can only work in client 010
    Any steps to solve this issue will be appreciated and awarded. Thanks

    Hi Experts,
    We are also having the same issue. We are in BI 7 SP 15.
    Is there any way to find the relation between the Bookmark ID and Query name? The favorite link is not working and getting the above error message. We are also not able to identify the query related to this favorite / bookmark link. Is there any table to identify for query and Bookmark?
    Can you experts advise urgently? Advance Thanks.
    Linda.

  • How to populate data into a tabular datablock from a cursor in oracle forms

    Hello experts,
                  I am new in oracle forms.I am using Oracle forms 11g with weblogic server 10.3.5 at windows 7.My issue is that I am trying to populate data from a cursor into a tabular datablock(record number property is set to 5).I am using a button press trigger with code as:
    declare
        cursor c3 is  select empno,ename from emp;
    begin
        go_block('C');
        first_record;
        loop
        open c3;
        Fetch C3 into :c.t1,
    :c.t2;
    Exit when :system.last_record = 'TRUE';
    next_record;
    Close C3;
        End loop;
        end;
    Everything is OK here except,I have 5 record rows in C datablock but only first record is fetched into datablock.I want all records are fetched into data block
    Thank you
    regards
    aaditya

    Yes
    when i m using below query,so binary data display not display actual format
    select UTL_RAW.CAST_TO_VARCHAR2 (DBMS_LOB.SUBSTR(SOAPRTFDESC,10,1)) from soaptxsection

  • Using cursor function in sql statement

    hi all
    can anyone plss explain why and when we will use cursor function in a sql statement like this and what is the difference while executing this sql statement with cursor function in comparison of a simple sql statement----
    select
    department_name,
    cursor (
    select last_name
    from employees e
    where e.department_id = d.department_id
    order by last_name
    ) the_employees
    from departments d
    thnx in advance

    RTFM
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref1452
    Cheers
    Sarma.

  • Run BW query from R/3, need output file saved on application server

    Hello all,
    We are currently working on BI 7.0. Is there a way where we can run a BW query from R/3 by some program or tcode? We need to run the BW query and use the output of that query as an input to some other custom program in R/3.
    If we can save the output file on application server than the R/3 program will pick up that file from there.
    Is there any standard delivered functionality that will allow us to do that or how can we achieve this.
    Can some help help with some suggestions or links?
    Thanks in advance.

    Hi,
       Refer the following threads:
    [Calling BW Query from R/3;
    [Saving Bex Report / query in BW App server;
    Regards.

  • Call BEX-Query from VBA with BEX-automatic login?

    Hi,
    I'm trying to call a query from VBA. I have two problems/questions:
    1. Automatic login?
    I want to do an automatic login. I found this peace of code here, but I get an error:
    Public Function  LogonToYourBW()
    ' create Logon & RFC-Handle
    logonToBW = False ‘ clear connect Flag the flag can be used to find out if connected or not
        'load SAP functionality by opening BEX file ( use your installation path)
            Workbooks.Open (“c:\sappc\bw\sapbex.xla”)
        With Run("sapbex.xla!sapbexGetConnection") ‘ call the connection
           ' Set the params for Auto logon
           .client = “YOUR CLIENT NO”
           .user = “YOUR BW USER”
           .Password = “YOUR BW PWD” ‘ I recommend to create a dummy reporting user for this task
           .Language = “YOUR LANGUAGE YOU LIKE TO USE FOR QUERY DISPLAY ( i.E.  “EN”)”
           .SystemNumber = “YOUR SYSTEM NO” ‘
           .ApplicationServer = “YOUR SERVER Name OR IP-ADDRESS”
           .UseSAPLOgonIni = FALSE 'important for automatic connection
           .logon 0, True ‘ This will provide a dialog to appear
            If .IsConnected <> 1 Then
                .logon 0, False
                If .IsConnected <> 1 Then Exit Function
            Else
                Set g_oFunction = CreateObject("SAP.Functions")
                Set g_oFunction.Connection = g_oConnection
            End If
        End With
        Run "sapbex.xla!sapbexinitConnection" ‘ this will enable the connection you just created
        logonToBW = True
    End Function
    The error is by this row:
    Set g_oFunction.Connection = g_oConnection
    Object is needed! How is the g_oConnection-object defined?
    2. How can I pass values for the parameters from VBA?
    If I open the query usually from SAP-BEX-Toolbar, after selecting the query, I get a parameter mask, where I must put in a value. How can I this automatize from VBA? Has anybody a short samplecode for that?
    Thank you for your help
    Stefan
    [email protected]

    Peter and others:
    What I really want to do … is write a stand-alone application that I can run from windows scheduler … that queries our BW for sales data for certain items (in a tabular form) … and pulls that data into a VB recordset, or a .NET dataset … so that I can insert the rows into another database (SQL Server, or Access) … I already know how to do all the data movement to/from datasets and databases … I just cannot figure out how to programmatically grab this sales data from BW … our company has “workbooks” already set up that aggregate WW sales information by region (IE, there is a separate workbook for each region of the world) … I can manually go into the Excel interface, tell it which items to pull the sales info for, and it dumps the data into the worksheet (organized by customer, and then by cat #) …
    So, what I’d like to do is write an app that will pull data every week or so from the BW (from each region’s sales invoice detail “workbook”), and insert it into another database that we use for reporting other, non-sales, data.
    Thoughts on this ?  Is there another, non-BEx method that is better ?
    thanks !!

  • How can we generate PDF file by passing a query from package to RDF?

    Hi Everyone,
    I am beginner as SQL Developer, I am stuck in one issue , that is regarding generating PDF or Excel file according to user parameters passed.
    Detail of Requirement :
    I have created one package it contains 2 functions and 1 Procedure .
    Also created xx_report.rdf for generating in PDF .
    getQuery Function Returns Query as output.
    getExcelFile function gets query as input and generate  and return CLOB file as OUTPUT.
    xx_Report  Procedure will take input CLOB file and export it to EXCEL file and save under a DEFAULT Location.
    When User Pass Excel as parameter we can generate the file , but now if User Passes the Parameter for PDF FILE then  client wants  to invoke RDF  passing same query(getQuery) to xx_Report.RDF and generate PDF from it .
    We have already Created the RDF for xx_Report
    How it is possible? to invoke RDF from PL SQL Package.
    (We are doing like this as in future if there are any changes in query we dont have to change in RDF or in Package )
    If not then please let me know the other way where i can get the PDF or EXCEL file as output according to users choice from RDF.
    ( We are not using XML PUBLISHER nor 3rd party tools)
    Only Oracle Reports Developer 11g 1.2.3.
    Please help me in this ....its urgent.
    Thanks and Regards,
    Harshil .

    Hello Narendra,
    (Specific to SAP POS General Merchandise)
    A  Tlog is binary file created by selling items via SAP POS. The file must be converted into ASCII by the use of a utility called cvtlog.exe or trickled to other systems. Once the tlog is converted to ASCII it contains all the information required to feed downstream systems such as ERP, POS DMu2026.etc.
    Hope that helps
    Angelo
    For detailed information on SAP POS dataflow and TLOG Formats  please see this link
    http://help.sap.com/saphelp_pos21/helpdata/en/be/5234a9eb44494ea0807925211e74c6/frameset.htm
    or navigate to Help.sap.com  and follow the below links
    Documentation -> SAP for Industries -> SAP for Retail

Maybe you are looking for

  • MIGO Goods Receipt - error with Movement Types on GR from Inbound Delivery

    Hi, I am getting an error message when processing a Goods Receipt (MIGO) against an Inbound Delivery with as 2 lines with different movement types, a standard 101 and a 970 (the latter being a user defined movement type for free goods). The error mes

  • Problem downloading ML in a MacBook

    Hi: I've tryed at least three times to download ML with my MacBook Air (2011) and all the times did not succeed. I've downloaded ML with my iMac with no problem, but the instalation module I've downloaded simply disapeared after installation, so I co

  • Personalization in BEx: transport activation to production ?

    Hi, on our development system (SAP BW 3.1) we have activated the "personalization in bex" via "BW Customizing - Implementation Guide - Business Information Warehouse - Reporting-relevant Settings - General Reporting Settings Activate Personalization

  • Multi step program

    Dear all, As a newbe here i would like to know if somebody reconizes this problem. I think i am looking for the obvious, though i cann't find it. In labview i would like to do the following: make  a screen in which a user can make a automated program

  • Unable to access device memory

    Hello there,  I'm having trouble trying to access the device memory. It's half full, but I haven't any files! I've tried a factory reset and a security wipe, but it still says that I've used up half the memory. When I try and update my phones softwar