Xmltable in cursor declaration - error!

Hi, I am using the following SQL:
select l.description
from XMLTABLE(XMLNAMESPACES('PostcodeAnywhere2' as "e"), '/e:InterimResults/e:Results/e:InterimResult' PASSING
XMLTYPE.createxml(ws_postcode_aw.getByPostcodeXML('WR2 6NJ','1', 'XML'))
COLUMNS description varchar2(400) PATH '//e:Description'
) l
which returns data OK.
However, when I incorporate it into a cursor, I get a "no more data to read from socket" error. When I replace the cursor with a simple "SELECT 'dasda' description FROM dual" the code complies OK. Can anyone assist with this? I have no idea what could be causing this. Code is included below:
CREATE OR REPLACE
PACKAGE BODY "GET_PC_DATA" AS
PROCEDURE disp_pc_data IS
v_str clob;
v_post_code varchar2(10) := 'WR2 6NJ';
v_fast_add_ret_xml xmltype;
v_pc_lookup_ret_xml xmltype;
TYPE c_get_addresses_t IS REF CURSOR;
c_get_addresses c_get_addresses_t;
TYPE r_get_addresses_t IS RECORD ( description varchar2(400));
r_get_addresses r_get_addresses_t;
FUNCTION getHouseNumber(p_desc IN varchar2) RETURN varchar2
IS
BEGIN
return substr(p_desc,1,instr(p_desc,v_1_line_add));
END;
BEGIN
OPEN c_get_addresses FOR
SELECT l.description
FROM XMLTABLE(XMLNAMESPACES('PostcodeAnywhere2' as "e"), '/e:InterimResults/e:Results/e:InterimResult' PASSING
XMLTYPE.createxml(ws_postcode_aw.getByPostcodeXML('WR2 6NJ','1', 'XML'))
COLUMNS description varchar2(400) PATH '//e:Description'
) l;
LOOP
FETCH c_get_addresses INTO r_get_addresses;
EXIT WHEN c_get_addresses%NOTFOUND;
v_str := v_str || getHouseNumber(r_get_addresses.description);
END LOOP;
CLOSE c_get_addresses;
END;
END;
Message was edited by:
steve_macleod

V('MY_ITEM') will be evaluated when the cursor is opened on (every) execution of the on-demand process.
Toon

Similar Messages

  • Invalid Cursor Position Error

    Help!
    I am using JRun3.1 and developing a web interface to a database. In this particular screen, I am using CachedRowSet (I downloaded this and added it to jrun classpath). I am getting "Invalid cursor position" error.
    I feel there is a problem with the usebean tag.
    This is my code:
    what is wrong with this?
    <%@ page language = "java" import="java.sql.*, java.util.*, javax.sql.*, sun.jdbc.rowset.*" %>
    <%
    String indSub = request.getParameter("indSub");
    String areaname = request.getParameter("selarea");
    %>
    <jsp:useBean id="crs" class="CachedRowSet" scope="session" >
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    crs.setUrl("jdbc:odbc:asphData");
    crs.setCommand("SELECT siccode, sicdesc from siccode where sictitle = '" + indSub + "'");
    crs.execute();
    %>
    </jsp:useBean>
    <%@ include file="header2.htm" %>
    <link rel="stylesheet" href="http://localhost:8100/empData/almis.css" type="text/css">
    <br>
    <br>
    <table align="center">
    <tr><td class="moduleDesign" align="center">Employers Database</td></tr>
    </table>
    <br><br>
    <font size="+2" face="verdana sans-serif">
    <form action="employerDetail.jsp" method="post">
    <p><center><font color="Blue">Employers in the �<%= indSub %>� Industry
    <br>
    SIC Code:�<%= crs.getString("siccode") %>
    <br>State: Utah<br>
    Region: �<%=areaname %><br>
    </font></center></p>
    <p>
    <b>Description:</b>�<%= crs.getString("sicdesc") %>
    </p>
    </form>
    <jsp:include page="footer2.htm" />
    </body>
    </html>
    srajaman2

    Never mind!
    I have to issue a next() command to get to the first line of the resultset!
    srajaman2

  • Maximum open Cursors Excedded error - for every transaction

    Hi All,
    I am getting the maximum opn cursors exceeded error suddenly for every single db transaction i am trying to make in my application. this did not happen previously during my developemnt and testing phase.
    I have a question here that i tried to google but failed to get satisfactory answer.:-
    When we use a cursor in the stored procedure to fetch data, how to make oracle automatically close the cursors once the stored proc finishes executin. Or is there something i have to follow other with my current open cursors limit to ensure this problem does not happen?
    Thanks,
    Chaitanya

    Hi Justin,
    My oracle stored procs are called by java framework. In each place i was closing the connection object but there were a few places where i was not closing the resultset object which directly pointed to my oracle cursor.
    I have closed the objects in such places and tried again but still i am getting the same error. Mit it be an instance where the oracle db is not allowing me to connect to it at all. Something like restarting it would help? Restarting the server where the oracle software is hosted.
    Please excuse my blatant ignorance in this issue.
    Thanks,
    Chaitanya

  • Invalid Cursor Position Error on Windows XP using CachedRowSet

    Hello, I don't know if this question lies here, but I thought it would be the well suited place so please pardon me if it isn't. I am trying to access multiple pages from my database on my XP machine but I am getting an "invalid cursor position" error when trying to access the next page. I don't know how this error is coming about because it works well on a Vista machine with no errors. I don't know if it is my drivers or something that brings about the problem. I am using mysql connecter 5.1.10, JRE 1.6.0_02 and windows XP SP2
    Below is a simple code that brings the error.
    package Admin; import javax.sql.rowset.CachedRowSet; import com.sun.rowset.CachedRowSetImpl; public class test { public void table() { try { CachedRowSet crs=new CachedRowSetImpl(); crs.setUrl("jdbc:mysql://host:3306/database");         crs.setUsername("User");         crs.setPassword("password"); crs.setCommand("select * from myTable"); int[] keys = {1}; crs.setKeyColumns(keys); crs.execute(); crs.last(); if(crs.getRow()>500){ //new overLimit(); } crs.setPageSize(3); crs.execute(); while (crs.next()) { System.out.print("page one----"); System.out.println(crs.getString(1)); } while(crs.nextPage()){ System.out.println("page two---"); while (crs.next()) { System.out.println("in page two"); System.out.println(crs.getString(1)); } } } catch (Exception e) { e.printStackTrace(); } } public static void main(String []args){ new test().table(); } }

    Yes I am running the same code on both machines. The output I get on the XP machine is shown below. I modified the code I posted earlier and replaced the "page two" text with "page (then page number)" and also omitted the "in page two" text for better readability---------PAGE 0---------
    DB09140110
    DU35463010
    EX29201810
    ---------PAGE 1---------
    EX38341510
    EX40471810
    KZ280299
    ----------PAGE 2---------
    LA130299
    LC130299
    MC081009
    ----------PAGE 3---------
    RZ300502
    VA130299
    VI020209
    ----------PAGE 4---------
    YX101008
    ZE220299
    ZF231105and vista....
    ----------PAGE 0---------
    EX38341510
    EX40471810
    KZ280299
    ----------PAGE 1---------
    LA130299
    LC130299
    MC081009
    ----------PAGE 2---------
    RZ300502
    VA130299
    VI020209
    ----------PAGE 3---------
    YX101008
    ZE220299
    ZF231105

  • Invalid cursor state error while executing the prepared statement

    hai friends,
    following code showing the invalid cursor state error while executing the second prepared statement.
    pls anyone help me
    String query = "select * from order_particulars where order_no=" + orderno + " order by sno";             psmt1 = conEntry.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);             rs1 = psmt1.executeQuery();             rs1.last();             intRowCount = rs1.getRow();             particularsdata = new Object[intRowCount][6];             rs1.beforeFirst();             if (intRowCount >= 1) {                 for (int i = 0; rs1.next(); i++) {                     particularsdata[0] = i + 1;
    particularsdata[i][1] = rs1.getString(3);
    particularsdata[i][2] = Double.parseDouble(rs1.getString(4));
    rs1.close();
    psmt1.close();
    query = "SELECT sum(delqty) FROM billdetails,billparticulars WHERE order_no= " + orderno + " and " +
    "billdetails.bill_no = billparticulars.bill_no GROUP BY particulars ORDER BY sno";
    psmt1 = conEntry.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    rs1 = psmt1.executeQuery(); //error showing while executing this line

    Also .. Why using arrays instead of collections? Shifting the cursor all the way forth and back to get the count is fairly terrible.
    With regard to the problem: either there's a nasty bug in the JDBC driver used, or you actually aren't running the compiled class version of the posted code.

  • Performance: Cursor declaration versus explicit query in BEGIN/END block

    Hi guys!
    Anyone knows if declare an explicit cursor inside a pl/sql block is faster than using a cursor declaration, and how fast it its?
    Which block runs faster? And how fast? ( once, twice, once and a half ? )
    Block1:
    DECLARE
    CURSOR cur_test (p1 NUMBER) IS
    SELECT field1, field2 FROM table WHERE field0 = p1;
    vf1 VARCHAR2(1)
    vf2 NUMBER;
    n NUMBER := 0;
    BEGIN
    OPEN cur_test ( n );
    FETCH cur_test INTO vf1, vf2;
    CLOSE cur_test;
    END;
    Block2:
    DECLARE
    vf1 VARCHAR2(1)
    vf2 NUMBER;
    n NUMBER := 0;
    BEGIN
    BEGIN
    SELECT field1, field2
    INTO vf1, vf2
    FROM table WHERE field0 = n;
    EXCEPTION
    WHEN others THEN
    null;
    END;
    END;
    I have LOOP in a cursor and may open/fetch/closes in this loop. I´m wondering how fast would it be if I change the open/fetch/closes to explicit query blocks...
    Thanks!
    Murilo

    If you expect your qurey to return a single row, you would generally want to use a SELECT ... INTO. You'd only want to use a cursor if you expect to return multiple rows of data.
    If you are doing this in a loop, I would strongly suspect that you should be letting Oracle join the tables in SQL rather than doing your own pseudo-join logic in PL/SQL. Letting SQL do the work of joining tables is going to generally be a sustantial performance difference. The difference between the two blocks you posted will be marginal at best.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • "Invalid Cursor Name" error at high volumes

    I have a customer using the Microsoft ODBC driver to connect from NT to a remote HP-UX box running Oracle. At transaction volumes of thousands per hour, they are receiving "Invalid cursor name' errors from the ODBC cursor library approximately a dozen times per hour. The number of cursors available on Oracle is configured at 1,250. Any idea what might be causing this would be appreciated. Thanks.

    Have you tried switching to the Oracle ODBC driver? It sounds like this may be a problem in the Microsoft driver. If that's the case, you'll probably want to bring the issue up with Microsoft.
    Justin

  • ORA-01000: maximum open cursors exceeded--Error

    Hi
    What is "ORA-01000: maximum open cursors exceeded" error,How to solve.
    Thanks
    Miseba

    Hi
    ORA-01000: maximum open cursors exceeded
    Other terms
    Oracle, open cursors, exchange infrastructure
    Reason and Prerequisites
    The parameter "open_cursors" is set too low. Long transactions, such as imports, may use up all available cursors and fail.
    Solution :
    THIS NOTE APPLIES TO XI 3.0 SP2 ONLY **
    if you encounter an exception that reports "ORA-01000: maximum open cursors exceeded" please adjust the open_cursors parameter as follows:
    If the BR*Tools exist on your system:
    1] directory: /usr/sap/<SID>/SYS/exe/run
    2] "brspace -c force -f dbparam -a change -p open_cursors -v 100000"
    3] directory: $ORACLE_HOME/dbs (Unix) or %ORACLE_HOME%/database (Win)
    4] change open_cursors parameter in init<SID>.ora to 100000
    If the BR*Tools are not available (2] above - command not found)
    1] change the open_cursors parameter as in 4] above
    2] restart DB, for changes to take effect. _ NOTE: This problem has been fixed with XI 3.0 SP3 (see note 735078)
    Plz asign points if helpfull.
    Regards
    Padmanabha

  • How to pass dynamically table name in my cursor declaration

    Hi:
    I am new. could you please let me know how to pass a table name dynamically in my cursor declaration? for instance I am declaring the following cursor in my pl/sql procedure:
    CURSOR crs_validate IS
    select * FROM <ACT_JUN_2006_LOB>;
    this ACT_JUN_2006_LOB table name, I should able to pass it when I open the cursor ... any help appreciated. thanks.
    srini

    Thanks all for the response. REFCURSOR does work: here is an example ... which I found on-line
    procedure emp_test(
    month varchar2,
    year varchar2)
    is
    type cur_typ is ref cursor;
    c cur_typ;
    query_str varchar2(200);
    emp_number number := 7900;
    salary number;
    name varchar2(30);
    Begin
    query_str := 'Select empno, ename, sal from emp_' || month ||'_'||year
    || ' where empno = :id';
    open c for query_str using emp_number;
    loop
    fetch c into emp_number, name, salary;
    exit when c%notfound;
    dbms_output.put_line(emp_number);
    end loop;
    close c;
    end;

  • Declaration error in calendar

    after i downloaded the calendar fmb and olb and pll i attached the library and dragged everything and when i compile the form it gives me declaration error in something called navigator , picklist and wizard the errors r:1) identifier "wizard.wizard_begin" must be declared 2)navigator.get_tree_name must be declared 3)navigator.display_tree must be declared 4)navigator.get_tree_element_value must be declared 5)wizard.wizard_show must be declared 6)refresh_trees must be declared 7)navigator.to_index must be declared
    8)navigator.get_tree_element_depth must be declared
    9)navigator.get_tree_element_parent must be declared
    10)pick_list.list_in must be declared 11)pick_list.list_out must be declared 12)pick_list.get_picklist_element_count must be declared 13)pick_list.get_picklist_selection must be declared 14)wizard.wizard_show must be declared 15)wizard.wizard_finish must be declared

    i use forms 10g the calendar pll and plx and olb after i dragged every thing and attached the pll i found error that some code using itemsit tells me that they r not declared

  • Maximum Open cursor  Exceeded error when deleting records from a table

    I have a strange problem.
    I have a table EMP_MASTER . Whenever I am trying to delete a record from this table, I am getting Maximum no. of open cursor exceeded error. But this error doesnot come when i delete from any other tables. And no. of open cursor is much lesser than OPEN_CURSOR parameter.
    All other tables (around 700) has foreign key constraint to this EMP_MASTER table for created_user paramater.
    Is it some thing like, when I am trying to delete a record from EMP_master, implicit cursor opens up and checks all referenced tables. and that limit gets exceeded ?
    Please help.
    Thanks,
    Raj

    Raji03 wrote:
    There is no trigger defined for this table.
    Is there a limit on which no.of references made to a column ? Because one column in this field, Emp no is being referenced in almost every other table. around 700 tables. Will it have any adverse effect ?That should have nothing to do with your problem directly. Again, those tables could have triggers defined on them and you are leaking cursors in one of those triggers (wild guess).
    An example of a table with many many others foreign key'd to it.
    create table parent_of_everything
       column1 number primary key
    insert into parent_of_everything select level from dual connect by level <= 1000;
    commit;
    --create 1000 tables all with foreign keys to the parent_of_everything
    begin
       for i in 1 .. 1000
       loop
          execute immediate 'create table child_' || i || ' (column1 number, column2 number, constraint child_' || i || '_fk foreign key (column1) references parent_of_everything (column1) on delete cascade)';
          execute immediate 'insert into child_' || i || ' select level, mod(level, ' || i || ') from dual connect by level <= 1000';
          commit;
       end loop;
    end;
    TUBBY_TUBBZ?delete parent_of_everything;
    1000 rows deleted.
    Elapsed: 00:02:53.03No problems were had (none were expected).
    Cleanup script.
    --remove the 1000 child tables
    begin
       for i in 1 .. 1000
       loop
          begin
             execute immediate 'drop table child_' || i || ' purge';
          exception when others
             then
                null;
          end;
       end loop;
    end;
    /

  • What are the "Shared Cursor (KKS) errors" = ORA-44201 - 44300

    Hi,
    Does anybody know what are the "Shared Cursor (KKS) errors" supposed to raise Oracle errors ORA-44201 till 44300?
    I am currently facing an 'ORA-44201: cursor needs to be reparsed' using Oracle DB EE 10.2.0.3!
    The 11g documentation is mentioning: "Action: Investigate possible causes of resource contention."
    Many Thanks in advance,
    Sébastien
    Brussels, Belgium

    Hi Rob,
    For sure, the error message generated by our 10.2.0.3 db is ORA-44201: cursor needs to be reparsed.
    I have posted a thread in Database - General:
    The environment: OS: Solaris 10 / DB: 10.2.0.3 / OWB: 10.2.0.2 / Workflow: 2.6.4
    I am facing this ORA-44201 when calling a function developed to create a materialized view on a prebuilt table:
    FUNCTION mv_create (p_mv_name IN VARCHAR2)
    RETURN NUMBER
    IS
    v_query VARCHAR2 (4000);
    v_active NUMBER;
    BEGIN
    SELECT mv_query, mv_active
    INTO v_query, v_active
    FROM mtd_materialized_view
    WHERE mv_name = p_mv_name;
    IF (v_active = 1)
    THEN
    EXECUTE IMMEDIATE 'CREATE MATERIALIZED VIEW '
    || p_mv_name
    || ' '
    || 'ON PREBUILT TABLE '
    || 'WITH REDUCED PRECISION '
    || 'ENABLE QUERY REWRITE AS '
    || v_query;
    END IF;
    RETURN 1;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    raise_application_error (-20250,
    'Create materialized view '
    || p_mv_name
    || ' failed: not found in metadata'
    RETURN 3;
    WHEN OTHERS
    THEN
    raise_application_error (-20251,
    'Create materialized view '
    || p_mv_name
    || ' failed unexpectedly: '
    || SQLERRM
    RETURN 3;
    END mv_create;
    -- End of mv_create function
    The error message:
    ORA-20251: Create materialized view MV_IA_COMN_MTLY failed unexpectedly:
    ORA-44201: cursor needs to be reparsed
    ORA-06512: at "CIS_DWH_FCT.CIS_L_FCT_XCH", line 507
    ORA-06512: at line 1
    I am totally blocked and need your help!!!
    Many Thanks in advance,
    Sébastien
    Brussels, Belgium

  • Cursor Invalidate error - ora-12842

    Hi All,
    A user is getting CURSOR INVALIDATE error on Select statement. Some times it works fine and some time it gives this error.
    Can any one tell me is it some thing related to the database settings or the only reason is SQL coding. DB - 9.2.0.6
    Thanks a lot..

    This error is caused by an event outside of the user's session, such as DDL against the object(s) they're querying or somebody flushing the db cache. Hence the irregular pattern of occurrences. Is there anything in the alert log or a trace file which might help you with your troubleshooting?
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Microsoft Cursor engine error 80004005 Data provider or other...

    I'm using Oracle 9i and ASP. And it works fine except for a query that returns like more than 6000 records and I get this error:
    Microsoft Cursor engine error 80004005
    Data provider or other service returned an E_FAIL status
    /Includes/ValidaUsr.asp, line 60
    The thing is that on my development server it works just fine, and on the production server it cracks. In line 60 I'm trying to read a record, and when the query returns like 1000 records it works perfect.

    Well, you're in a somewhat bad spot. You should generally use server-side cursors and you're using client-side. Likewise, you're using Microsoft's OLE DB Driver for Oracle (known for issues) instead of Oracle's :(
    For the Microsoft driver, the only thing I can think of is switching to server-side cursors. I know that's not much help, but I can't think of anything else that would cause that kind or odd error.
    As I'm done with lunch now, I gotta get back to work.

  • DBMS_PIPE : NOT DECLARED ERROR 발생 시

    제품 : PL/SQL
    작성날짜 : 1996-10-30
    DBMS_PIPE NOT DECLARED ERROR 발생 시
    ====================================
    발생원인 1)
    DBMS_PIPE는 oracle install시에 $ORACLE_HOME/rdbms/admin/catproc.sql을
    실행함으로써 생성되도록 되어 있는 stored package이다.
    다른 stored package(DBMS_OUTPUT....)등은 생성직후 sys를 owner로한
    stored package에 대해 public synonym을 생성한 후 바로 이 synonym에
    대해 public에게 execute previlege가 grant되지만 DBMS_PIPE는 생성만
    되도록 되어 있기 때문에 사용하고자 하는 user에게 별도의 grant작업이
    필요하다.
    -> 확인사항 및 해결 방법
    1) sqldba에서
    select * from dba_objects where object_name = 'DBMS_PIPE';
    를 수행하여 DBMS_PIPE에 관한 자료가 sys가 owner인 package
    spec,package body,synonym만 나타나야 한다.
    2) sqldba에서
    grant execute on DBMS_PIPE to user_name;
    을 실행하여 해당 user에게 grant한다.
    발생원인 2)
    DBMS_PIPE는 sys가 owner이어야 한다.
    user의 실수로 system이나 다른 별도의 user로 connect하여 catproc.sql을
    실행한 경우에 발생한다.
    -> 확인사항 및 해결방법
    1) sqldba에서
    select * from dba_objects where object_name = 'DBMS_PIPE';
    를 수행하여 DBMS_PIPE에 관한 자료가 sys나 public이 아닌 다른
    user가 owner로 되어 있는 DBMS_PIPE object를 drop시킨다.
    2) sqldba에서
    grant execute on DBMS_PIPE to user_name;
    을 실행하여 해당 user에게 grant한다.

    Your comments are inappropriate.
    First of all, documentation links outside Oracle might not contain the correct documentation, as Oracle fixes documentation bugs silently.
    Secondly, you should not post links to desupported release. You seem to have assumed the 8.1.5 solution still applies to newer releases, which is correct in this case but not necessarily in all cases.
    Finally in the time you took to flame Saubhik you could have helped someone else out.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for