Func returns Cursor problems from JDBC

I'm wanting to hide implementation behind a function and call from JDBC / SQL
select a,b,c from tbl where d in ( myFunc ( ? ) )
My function is:
FUNCTION F_GET_DEPTS
  ( sup_cuid IN varchar2 )
  RETURN  sys_refcursor IS
my_depts sys_refcursor;
BEGIN
    open my_depts for select dept_id from department where lead_cuid = sup_cuid;
    return my_depts;
END;I test from sql navigator:
select * from f_get_depts( 'mm9546' )
or
select f_get_depts( 'mm9546' ) from dual
both fail with different error messages.
Thanks for help
curt

Procedure Ref_Types_Getall (p_recordset     OUT          PKG.cursor_type,
p_error_code      OUT      Number) is
Begin
p_error_code:=ERR_OK;
If Not p_recordset%ISOPEN then
     open p_recordset for Select * from COM_ASS_REFERENCE_TYPES_TAB where Upper(user_edit)='Y' order by description;
End if;
Exception when others then
p_error_code:=ERR_ORA;
End Ref_types_getall;
the above procedure returns a ref cursors, if u need to use this in SQL plus
u should declare a variable like this..
var c refcursor,
var ecode number;
and then execute like this
exec Ref_types_getall(:c,:ecode)
after it executes, type
print c
the above print stmt will print the resultset
print ecode
this will print the error code if any has been set
HTH
Srini

Similar Messages

  • NullpointerException while returning XML bean from JDBC Control

    Hi,
    I have a simple jdbc control method which returns multiple rows of a table. i am trying to get the data in XML bean format and followed the instruction provided in the help documentation.
    None of the columns in table has null values.
    The exception I am getting is
    Exception in getActiveAlertList
    java.lang.NullPointerException
    at org.apache.beehive.controls.system.jdbc.RowToXmlObjectMapper.mapRowToReturnType(RowToXmlObjectMapper.java:102)
    at org.apache.beehive.controls.system.jdbc.DefaultXmlObjectResultSetMapper.mapToResultType(DefaultXmlObjectResultSetMapper.java:59)
    at org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:365)
    at org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:223)
    Any help is appreciated.

    Hi!
    I?m facing this same problem.
    Have you found a solution?
    I also tried to migrate an WL 8 application, that works with a DB Control, but got the error anyway.
    If you, or someone else, found the solution, please share. I?d appreciate.
    Thanks.
    Gustavo

  • How to return cursor from procedure to jdbc

    plz help me through example of code as wl as procedure where.... return cursor from procedure to jdbc

    SET QUOTED_IDENTIFIER OFF
    GO
    SET ANSI_NULLS OFF
    GO
    CREATE procedure anil3 @count INT OUT,@opcode INT OUT,@total_tiff INT OUT
    as
    declare @query2 varchar(300),@tiff_count int,@query1 varchar(300)
    set @query1='declare move_cursor   cursor forward_only static for
    select count(opcode),opcode from TABLE1 group by opcode
    open move_cursor'
    exec(@query1)
    fetch next  from move_cursor into @count,@opcode
    set @opcode="'"+@opcode+"'"
    set @total_tiff=0
    while (@@fetch_status=0)
    begin
         set @query2='declare move_cursor2  cursor static for '+
         ' select count(tiff) from TABLE2  where opcode='+@opcode+
           ' open move_cursor2 '
         exec(@query2)
         fetch next  from move_cursor2 into @tiff_count
         while (@@fetch_status=0)
         begin
              set @total_tiff=@total_tiff+@tiff_count
              fetch next  from move_cursor2 into @tiff_count
         end
         close move_cursor2
         deallocate move_cursor2
    print  @total_tiff
    print @count
    print @opcode
    fetch next  from move_cursor into @count,@opcode
    end
    close move_cursor
    deallocate move_cursor
    SET QUOTED_IDENTIFIER OFF
    GO
    SET ANSI_NULLS ON
    GO******************************************************************************
    above this is sql server 2000 PL/SQL and i hv to get the value
    print @total_tiff
    print @count
    print @opcode
    through JDBC
    plz help me out how to return Cursor to JDBC and HOW toPRINT THESE THREE VALUE @total_tiff, @count, @opcode through JDBC
    get this values through JDBC

  • OCI8: returning cursors from stored procedures

    The short version of my question is:
    In OCI8, how do open a cursor from the database stored procedure, return it to my C++ program and fetch from it, given that in OCI8 cursors and cursor functions are becoming obsoleted?
    The long version of the same question is:
    I am converting my C++ code from the Oracle 7.3 OCI driver to the Oracle8 OCI driver. One thing I did very frequently in Oracle 7.3 OCI code is open a multi-row select cursor within a stored procedure and return that cursor to my program. In the program, I would then do the fetching with the returned cursor. This was very useful, as it allows me to change the queries in the stored procedure (for example, to append information to certain columns or make some data in all uppercase) without recompiling the application due to a changed SQL string.
    My 7.3 psuedocode is as follows:
    stored procedure def:
    TYPE refCurTyp IS REF CURSOR;
    FUNCTION LoadEmployeeData RETURN refCurTyp;
    stored procedure body:
    FUNCTION LoadEmployeeData RETURN refCurTyp IS
    aCur refCurTyp;
    BEGIN
    OPEN aCur FOR
    SELECT emp_id, emp_name
    FROM employee_table
    ORDER BY emp_name;
    return aCur;
    END;
    OCI code: // all functions are simplified, not actual parameter listing
    // declare main cursor variable #1 and return cursor variable #2
    Cda_Def m_CDAstmt, m_CDAfunction;
    // open both cursors
    oopen(m_CDAstmt, ...);
    oopen(m_CDAfunction, ...);
    // bind cursor variable to cursor #2
    oparse(&m_CDAstmt, "BEGIN :CUR := MYPACKAGE.LoadEmployeeData; END;");
    obindps(&m_CDAstmt, SQLT_CUR, ":CUR", &m_CDAfunction);
    // run cursor #1
    oexn(&m_CDAstmt);
    // bind variables from cursor #2, and fetch
    odefineps(&m_CDAfunction, 1, SQLT_INT, &m_iEmpId);
    odefineps(&m_CDAfunction, 2, SQLT_CHAR, &m_pEmpName);
    while (!ofen(&m_CDAfunction))
    // loop: do something with fetch
    // values placed in m_iEmpID and m_pEmpName
    This works perfectly, and has really helped to make my code more maintainable. Problem is, in Oracle 8 OCI both cursors and the cursor functions (such as oopen()) are becoming obsoleted. Now it uses statement and environment handles. I know I can still use Cda_Def and cursors--for a while--within OCI8, but I need to know the official up-to-date method of returning a cursor from the database and fetching within my C++ code. Any code fragment, or explanation of what I need to do in OCI8 would be appreciated (perhaps I need to bind to a statement handle instead? But the stored procedure still returns a cursor.)
    The Oracle8 OCI has a new SQLT_ type, SQLT_RSET, which the header file defines as "result set type". Unfortunately, it's almost completely undocumented in the official documentation. Am I supposed to use this instead of the obsolete SQLT_CUR?
    Thanks,
    Glen Mazza

    Email me diorectly and I will get you some code that might help. I fail to see the relevance of posting this type of information in the JDeveloper forum.

  • Performance problem with slow VIEW from JDBC (fast from SQL Developer)

    Hi all,
    I'm experiencing following problem and would like to know if someone else also hit this one before and has a suggestion how to solve it:
    I have a pretty complicated SELECT statement that per definition returns only a few rows (~30). With no further optimization it takes ~20 seconds to return the full dataset in Oracle SQL Developer. If you add the */+ PUSH_PRED(name_of_some_inner_view) /* hint (hint is correct, stars got eaten by the OTN-forum syntax), the statement takes less than 0.5s to execute (still in SQL Developer). I saved the statement with the hint as VIEW. Selecting from the VIEW in SQL Developer is also fast.
    Now if I call the statement from JDBC (Tomcat webapp), I can see from the server console that the statement is 1:1 100% the same as the one I execute in SQL Developer. Nevertheless it takes about 20 seconds to complete.
    Here my details:
    SELECT banner FROM v$version;
    BANNER                                                                        
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production             
    PL/SQL Release 11.2.0.2.0 - Production                                          
    CORE     11.2.0.2.0     Production                                                        
    TNS for 32-bit Windows: Version 11.2.0.2.0 - Production                         
    NLSRTL Version 11.2.0.2.0 - Production                                          
    JDBC Driver used: some old odbc14.jar as well as current odbc6.jar for 11.2.0.2.0 from http://www.oracle.com/technetwork/da...10-090769.html
    SQL Developer: current version 3.2.20.09From my reading this could go wrong:
    - JDBC doesn't know the VIEW's column data types and Oracle behaves mysterious because of this (=there must be more to the SELECT than just the string, some meta-information)
    - For some reason the hint inside the VIEW is not used (unlikely)
    I also tried a Table Function/Pipelined table and selected from it as a workaround, but the result is the same: Selecting from Function is fast from SQL Developer, but slow from JDBC. All other statements that come from JDBC are as fast as they should be. I really don't know what to think of this and where the error might be.
    Is there some setting that tells Oracle not to use hints when called from JDBC?
    Thank you & Best regards,
    Blama

    Hi Bawer,
    that's what I'm thinking. Unfortunately I can't post it, as it is library code (not my lib). But in the debug-output I can see the SQL-String sent to the DB (which does include the hint).
    But I find the 2nd option you mention more likely anyway: Even if I put the hint into a VIEW and select from the view, the time-difference is there (it's even there if I use Table Functions/Pipelined table and select from the function).
    So I'd think it is more likely that something else is happening (e.g. Oracle is configured in a way that it does not use hints when called from JDBC or similar. Or the library sets some session options in order to prevent the usage of hints). But I don't know if there is even the possibility of doing so.
    Does the Oracle JDBC driver have the option to set these options?
    Does the Oracle DB have the option to set sth. like "ALTER SESSION SET dontUseHints = 'Y';"

  • Stored procedure call with REF CURSOR from JDBC

    How can I call a SP with a REF CURSOR OUT parameter from JDBC?

    This is a breeze.
    CallableStatement oraCall = oraConn.prepareCall("BEGIN PKG_SOMETHING.RETURNS_A_SP(?);END;");
    oraCall.registerOutParameter(1,oracle.jdbc.driver.OracleTypes.CURSOR);
    oraCall.execute();
    ResultSet rsServList = (ResultSet) oraCall.getObject(1);
    ... use ResultSet ...
    rsServList.close();
    oraCall.close();
    slag

  • Return a string from a method: a problem in C++ but is it a problem in java

    I have a method which return a String from it as:
    String pattern(short i)
    String s="":
    if (i==1)
    s = "test1";
    else
    s = "test2";
    return s;
    Since s is a local vaariable to pattern(), does the code above
    create problems? I know it is a problem for C++ since the local
    variable memory address will be reused by others and thus the
    returned value may take other values sometime later or not
    readable.

    Actually, this is not a problem in C++ either if you
    just use the string class instead of the old-style
    char* from C.True, I was assuming he/she meant (in C++):
    char mylocalbuf[80];
    // put stuff in mylocalbuf here
    return mylocalbuf;
    which would be very very bad to do indeed.

  • Invalid cursor problem

    Steve,
    Were you ever able to look at this item? In the meantime, my work around was to do a separate xsql query for each sub-query(cursor) and then append nodes in my DOM as I went along. But, I would like to help this tool be better. I think I have determined that if one of the sub-select/sub-cursor queries doesn't return anything, I get the "invalid cursor" error. Does that make sense to you? I think that if a the result should still be a blank node
    ( </NODE> ). What do you think?
    thanks,
    chad.
    -----Original Message-----
    From: Chad Small
    Sent: Friday, September 22, 2000 9:31 AM
    To: 'Steve Muench'
    Subject: RE: LONG data type and subsequent CURSOR's question/problem
    I attached two files:
    1. file with sql script - you'll have to change the schema.
    2. file with code. Two sections
    a. 1st with jdbc result set code
    b. 2nd with OracleXMLQuery
    I comment out one or the other code section to run one or the other.
    If you need any other information, please let me know.
    thanks,
    chad.
    -----Original Message-----
    From: Steve Muench [mailto:[email protected]]
    Sent: Thursday, September 21, 2000 4:14 PM
    To: Chad Small
    Subject: Re: LONG data type and subsequent CURSOR's question/problem
    Is it possible to send me CREATE TABLE script with one row
    of sample data inserted that reproduces the problem?
    Thanks.
    Steve Muench, Lead XML Evangelist & Consulting Product Manager
    BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG
    Author "Building Oracle XML Applications", O'Reilly http://www.oreilly.com/catalog/orxmlapp/
    ----- Original Message -----
    From: "Chad Small" <[email protected]>
    To: "'Steve Muench'" <[email protected]>
    Sent: Thursday, September 21, 2000 3:56 PM
    Subject: RE: LONG data type and subsequent CURSOR's question/problem
    |
    | Using the same query string on both programs:
    |
    | String xsqlString =
    | "SELECT hwp.publish_document_id, hwp.topic_id, hwp.section_id,
    | hwp.body, " +
    | "CURSOR( SELECT hws.name as section_name " +
    | "FROM health.section hws " +
    | "WHERE hwp.section_id = hws.section_id) as section " +
    | "FROM health.publish_document hwp " +
    | "WHERE hwp.publish_document_id IN (13729, 1033, 11695)";
    | ____________________________________________________________________________
    | ______
    | This works - simple JDBC program :
    |
    | PreparedStatement stmt = conn.prepareStatement(xsqlString);
    | ResultSet rs = stmt.executeQuery();
    |
    | int n=1;
    | while( rs.next() ) {
    | System.out.println(n+": publish_document_id =
    | "+rs.getInt("publish_document_id"));
    | System.out.println(n+": topic_id = "+rs.getInt("topic_id"));
    | System.out.println(n+": section_id = "+rs.getInt("section_id"));
    | n++;
    | }
    | rs.close();
    | stmt.close();
    | conn.close();
    | ____________________________________________________________________________
    | ______
    | This does not work - simple OracleXMLQuery:
    |
    | OracleXMLQuery qry = new OracleXMLQuery(conn, xsqlString);
    | System.out.println("after\n");
    | // structure the generated XML document
    | qry.setMaxRows(1); // set the maximum number of rows to be returned
    | qry.setStyleSheet("file:D:\\xsql\\bin\\healthwise.xsl"); // sets the
    | stylesheet
    |
    | // get the XML document in string format
    | String xmlString = qry.getXMLString();
    |
    | // print out the XML document
    | System.out.println(" OUTPUT IS:\n"+xmlString);
    | conn.close();
    | ____________________________________________________________________________
    | _______
    | -> get this:
    |
    | OUTPUT IS:
    | <?xml version = '1.0'?>
    | <ERROR>oracle.xml.sql.OracleXMLSQLException: Stream has already been
    | closed</ERROR>
    |
    |
    | java.sql.SQLException: ORA-01001: invalid cursor
    |
    | at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
    | at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    | at oracle.jdbc.ttc7.Oclose.receive(Oclose.java:126)
    | at oracle.jdbc.ttc7.TTC7Pr otocol.close(TTC7Protocol.java:493)
    | at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:467)
    | at
    | oracle.jdbc.driver.OracleConnection.close_statements(OracleConnection.java:1
    | 141)
    | at oracle.jdbc.driver.OracleConnection.close(OracleConnection.java:537)
    | at com.healthecare.search.apelon.xmlquerydb.main(xmlquerydb.java:116)
    | at symantec.tools.debug.Agent.runMain(Native Method)
    | at symantec.tools.debug.MainThread.run(Agent.java:48)
    |
    |
    | Please advise.
    |
    | thanks,
    | chad.
    | -----Original Message-----
    | From: Steve Muench [mailto:[email protected]]
    | Sent: Thursday, September 21, 2000 1:46 PM
    | To: Chad Small
    | Subject: Re: LONG data type and subsequent CURSOR's question/problem
    |
    |
    | Are you able to test the query that does cause the
    | problem with:
    |
    | -> The command-line XSU utility
    | -> A simple JDBC program that creates a prepared statement
    | with this query and executes it to produce a result set
    |
    | I want to know if the problem is in JDBC or XSU.
    |
    | ______________________________________________________________
    | Steve Muench, Lead XML Evangelist & Consulting Product Manager
    | BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG
    | Author "Building Oracle XML Applications", O'Reilly
    | http://www.oreilly.com/catalog/orxmlapp/
    |
    | ----- Original Message -----
    | From: "Chad Small" <[email protected]>
    | To: "'Steve Muench'" <[email protected]>
    | Sent: Thursday, September 21, 2000 1:09 PM
    | Subject: RE: LONG data type and subsequent CURSOR's question/problem
    |
    |
    | | The problem does NOT occur in (1) -simple query.
    | | And yes, the problem does occur in (2) - in combination with CURSOR.
    | |
    | | thanks,
    | | chad.
    | |
    | | -----Original Message-----
    | | From: Steve Muench [mailto:[email protected]]
    | | Sent: Thursday, September 21, 2000 11:44 AM
    | | To: Chad Small
    | | Subject: Re: LONG data type and subsequent CURSOR's question/problem
    | |
    | |
    | | Trying to isolate the problem a little...
    | |
    | | (1) Does the problem occur if you do a simple query like:
    | |
    | | SELECT body FROM table
    | |
    | | with just the LONG column?
    | |
    | | (2) Or does it only happen in combination with CURSOR() ?
    | |
    | | ______________________________________________________________
    | | Steve Muench, Lead XML Evangelist & Consulting Product Manager
    | | BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG
    | | Author "Building Oracle XML Applications", O'Reilly
    | | http://www.oreilly.com/catalog/orxmlapp/
    | |
    | | ----- Original Message -----
    | | From: "Chad Small" <[email protected]>
    | | To: <[email protected]>
    | | Sent: Thursday, September 21, 2000 10:24 AM
    | | Subject: LONG data type and subsequent CURSOR's question/problem
    | |
    | |
    | | | Hello Steve,
    | | |
    | | | First I want to thank-you for all of the support you put into Oracle's
    | XML
    | | | board. I just ordered your book from Fatbrain and it's on back order!
    | I
    | | | tried asking my question on the board and didn't have any luck getting
    | any
    | | | responses - maybe people didn't understand my question. I'm desperate
    | for
    | | | this to work and really need some guidance.
    | | |
    | | | I'm using the command line to extract data from tables to XML
    | | | (.bin\xsql\bin\xsql healthwise.xsql chad.xml). Everything works
    | | wonderfully
    | | | until I add a LONG data type to the mix. Here is my xsql before the
    | LONG:
    | | |
    | | | <?xml version="1.0"?>
    | | | <!-- healthwise_xslt.xsql -->
    | | | <xsql:query
    | | | xmlns:xsql="urn:oracle-xsql"
    | | | connection="healthwise_dev2"
    | | | max-rows="22050" >
    | | |
    | | | SELECT hwp.publish_document_id, hwp.topic_id, hwp.section_id,
    | | | CURSOR( SELECT hws.name as section_name
    | | | FROM health.section hws
    | | | WHERE hwp.section_id = hws.section_id) as section,
    | | | CURSOR( SELECT hwk.name as keyword_name
    | | | FRO M health.keyword hwk, health.map_keyword_object
    | | | hwmko, health.object hwo
    | | | WHERE (hwp.publish_document_id =
    | | | hwo.publish_document_id) and
    | | | (hwo.object_id = hwmko.object_id) and
    | | | (hwmko.keyword_id = hwk.keyword_id) ) as keywords,
    | | | CURSOR( SELECT hwt.name as topic_name,
    | | | CURSOR( SELECT hwts.name as topic_synonym_name
    | | | FROM health.topic_synonym hwts
    | | | WHERE hwt.topic_id = hwts.topic_id) as
    | | | topic_synonyms,
    | | | CURSOR( SELECT hwc.name as catagory_name
    | | | FROM health.category hwc,
    | | health.map_category_topic
    | | | hwmct
    | | | WHERE (hwt.topic_id = hwmct.topic_id) and
    | | | (hwmct.category_id = hwc.category_id) ) as catagories
    | | | FROM health.topic hwt
    | | | WHERE hwp.topic_id = hwt.topic_id) as topic
    | | | FROM health.publish_document hwp
    | | | WHERE hwp.publish_document_id IN (13729, 1033, 11695)
    | | | </xsql:query>
    | | |
    | | |
    | | | I'm using this in combination with a XSLT and get this output -
    | Beautiful!
    | | -
    | | | just what I want, less my LONG body field :
    | | |
    | | | <?xml version="1.0" encoding="UTF-8"?>
    | | | <CONTENT>
    | | |
    | | |
    | |
    | <URL>http://healthecare140:7601/medical/medicalDocument.jsp?page=medical&#38
    | | | ;topic=10744&#38;item=7</URL>
    | | | <TITLE>Graft versus Host Disease</TITLE>
    | | | <RANK1>
    | | | <RANK1_DSCR>GVHD</RANK1_DSCR>
    | | | </RANK1>
    | | | <RANK2/>
    | | | <RANK3>
    | | | <RANK3_DSCR>Rare Disorders</RANK3_DSCR>
    | | | </RANK3>
    | | |
    | | |
    | |
    | <URL>http://healthecare140:7601/medical/medicalDocument.jsp?page=medical&#38
    | | | ;topic=910&#38;item=4</URL>
    | | | <TITLE>Hypnosis</TITLE>
    | | | <RANK1/>
    | | | <RANK2>
    | | | <RANK2_DSCR>Hypnotherapy</RANK2_DSCR>
    | | | </RANK2>
    | | | <RANK3/>
    | | |
    | | |
    | |
    | <URL>http://healthecare140:7601/medical/medicalDocument.jsp?page=medical&#38
    | | | ;topic=12344&#38;item=9</URL>
    | | | <TITLE>Low Back Problems -- Computerized axial tomography (CAT scan,
    | | | CT scan)</TITLE>
    | | | <RANK1>
    | | | <RANK1_DSCR>CT scan (computerized tomography),
    | | | back</RANK1_DSCR>
    | | | <RANK1_DSCR>CT scan, back</RANK1_DSCR>
    | | | <RANK1_DSCR>Back, CT scan of</RANK1_DSCR>
    | | | <RANK1_DSCR>Computed axial tomography (CAT) scan,
    | | | back</RANK1_DSCR>
    | | | </RANK1>
    | | | <RANK2/>
    | | | <RANK3/>
    | | | </CONTENT>
    | | |
    | | |
    | | | BUT, as soon as I add the LONG body field into the query (in BOLD):
    | | |
    | | | <?xml version="1.0"?>
    | | | <!-- healthwise_xslt.xsql -->
    | | | <xsql:query
    | | | xmlns:xsql="urn:oracle-xsql"
    | | | connection="healthwise_dev2"
    | | | max-rows="22050" >
    | | |
    | | | SELECT hwp.publish_document_id, hwp.topic_id, hwp.section_id,
    | hwp.body,
    | | | <--------- hwp.body is the LONG
    | | | CURSOR( SELECT hws.name as section_name
    | | | FROM health.section hws
    | | | WHERE hwp.section_id = hws.section_id) as section,
    | | | CURSOR( SELECT hwk.name as keyword_name
    | | | FROM health.keyword hwk, health.map_keyword_object
    | | | hwmko, health.object hwo
    | | | WHERE (hwp.publish_document_id =
    | | | hwo.publish_document_id) and
    | | | (hwo.object_id = hwmko.object_id) and
    | | | (hwmko.keyword_id = hwk.keyword_id) ) as keywords,
    | | | CURSOR( SELECT hwt.name as topic_name,
    | | | CURSOR( SELECT hwts.name as topic_synonym_name
    | | | FROM health.topic_synonym hwts
    | | | WHERE hwt.topic_id = hwts.topic_id) as
    | | | topic_synonyms,
    | | | CURSOR( SELECT hwc.name as catagory_name
    | | | FROM health.category hwc,
    | | health.map_category_topic
    | | | hwmct
    | | | WHERE (hwt.topic_id = hwmct.topic_id) and
    | | | (hwmct.category_id = hwc.category_id) ) as catagories
    | | | FROM health.topic hwt
    | | | WHERE hwp.topic_id = hwt.topic_id) as topic, hwp.body
    | | | <---------------- I tried it here too
    | | | FROM health.publish_document hwp
    | | | WHERE hwp.pu blish_document_id IN (13729, 1033, 11695)
    | | | </xsql:query>
    | | |
    | | |
    | | | I get this error:
    | | | oracle.xml.sql.OracleXMLSQLException: Stream has already been closed
    | | |
    | | |
    | | | However, this works:
    | | |
    | | | <?xml version="1.0"?>
    | | | <!-- healthwise_xslt.xsql -->
    | | | <xsql:query
    | | | xmlns:xsql="urn:oracle-xsql"
    | | | connection="healthwise_dev2"
    | | | max-rows="22050" >
    | | |
    | | | SELECT hwp.publish_document_id, hwp.topic_id, hwp.section_id, hwp.body
    | | | <--------- hwp.body is the LONG
    | | | FROM health.publish_document hwp
    | | | WHERE hwp.publish_document_id IN (13729, 1033, 11695)
    | | | </xsql:query>
    | | |
    | | |
    | | | Do I have to pull this out into code and stream the long into a string
    | and
    | | | build a DOM and then go to XML from that? Or something along those
    | lines?
    | | | And if this is the case, can you point me to some sample code.
    | | | I don't have the option of changing the LONG to something that doesn't
    | | have
    | | | to be streamed as suggested in this
    | | |
    | |
    | doc(http://technet.oracle.com/doc/oracle8i_816/java.816/a81354/basic4.htm).
    | | |
    | | |
    | | | If we can come to a conclusion on this, I will be the xsql-long
    | evangelist
    | | | on the board!
    | | |
    | | | Thank-you for you time,
    | | | chad. <[email protected]>
    | | |
    | | |
    | |
    |
    null

    Just wanted to post Steve's response to this question, in case others have problems with LONG data types and CURSORS in their .xsql queries (thanks Steve!):
    I can reproduce the problem with your testcase.
    I've filed Bug Number 1472008.
    You can workaround the problem by using CLOB
    instead of LONG in your table.
    You can use to TO_LOB() function in a CREATE TABLE...AS SELECT...
    or in an INSERT INTO TABLE...SELECT... to easily
    convert existing LONG content into CLOBs.
    null

  • Problems with JDBC/Oracle version and types.

    Hello all,
    I am having a boring version problem here. We, recently, changed our Oracle 8i (8.1.7) for a Oracle 9i (9.2.0.6).
    We have several Java/J2EE applications running on JBoss and accessing that Oracle Database.
    We haven´t changed the JDBC driver version and we started to notice that a lot of cursors have been stucked and are not been closed.
    Searchin in Google and metalink we´ve decided to update ou JDBC driver version from classes12_8.1.7.1.jar for this ojdbc14.jar (9.2.0.5).
    After this change we started to have a lot of ClassCastExceptions, specially in this case:
    When my app call this procedure:
    MY_PROC(USR IN VARCHAR2, ID OUT NUMBER)
    in my Java app, using such code:
    CallableStatement call = conn.prepareCall("{ call MY_PROC(?,?) }",
    ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    call.setString(1, user);
    call.registerOutParameter(2, OracleTypes.INTEGER);
    call.executeQuery();
    BigDecimal id = (BigDecimal) call.getObject(2);
    Instead of BigDecimal, the JDBC driver returns me an Integer object, using driver version 9. With the 8i driver it works fine (although we still have the cursor problem).
    The fact is, we have a lot of points to change in our apps if we change the driver version, which is not good.
    Is there any other suitable thing we can do to solve our problem and minimize our work.
    Recall we use Java / JBoss / Oracle 9i.
    Thanks
    Daniel

    Hello all,
    I am having a boring version problem here. We, recently, changed our Oracle 8i (8.1.7) for a Oracle 9i (9.2.0.6).
    We have several Java/J2EE applications running on JBoss and accessing that Oracle Database.
    We haven´t changed the JDBC driver version and we started to notice that a lot of cursors have been stucked and are not been closed.
    Searchin in Google and metalink we´ve decided to update ou JDBC driver version from classes12_8.1.7.1.jar for this ojdbc14.jar (9.2.0.5).
    After this change we started to have a lot of ClassCastExceptions, specially in this case:
    When my app call this procedure:
    MY_PROC(USR IN VARCHAR2, ID OUT NUMBER)
    in my Java app, using such code:
    CallableStatement call = conn.prepareCall("{ call MY_PROC(?,?) }",
    ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    call.setString(1, user);
    call.registerOutParameter(2, OracleTypes.INTEGER);
    call.executeQuery();
    BigDecimal id = (BigDecimal) call.getObject(2);
    Instead of BigDecimal, the JDBC driver returns me an Integer object, using driver version 9. With the 8i driver it works fine (although we still have the cursor problem).
    The fact is, we have a lot of points to change in our apps if we change the driver version, which is not good.
    Is there any other suitable thing we can do to solve our problem and minimize our work.
    Recall we use Java / JBoss / Oracle 9i.
    Thanks
    Daniel

  • Returning result sets from PL/SQL procedure to client app.

    I was wondering if its possible in Oracle PL/SQL to DECLARE, OPEN a cursor and exit
    the procedure without closing the cursor
    and then retrieve the resultset from
    the client.
    Pl let me know..
    null

    Yes, you need to use one OUT parameter in your PL/SQL procedure
    to pass the cursor variable to
    Java code. You can also return that as a return variable of
    PL/SQL function. Get the cursor variable from the resultset using
    Types.CURSOR data type and then proceed as usual.
    Enrique (guest) wrote:
    : Thank you Rajib for your prompt reply. I have been programming
    a
    : lot in Transact SQL( MSSQL ), but I am new to Oracle and I need
    : to migrate MSSQL procedures to Oracle. I will try to use the
    : refCursors. One more question, how do I pass the cursors back?
    : With OUT parameters? In MSSQL you do not need to specify OUT
    : parameters if you are returning a result set.
    : Once Again,
    : Thank you
    : Rajib (guest) wrote:
    : : You can return a variable of refcursor type from your PL/SQL
    : : procedure (PL/SQL 2.3 or higher) to Java code. Oracle JDBC
    has
    : a
    : : refcursor data type. Now you can use this cursor as a
    : resultset.
    : : Enrique (guest) wrote:
    : : : Hi All,
    : : : I am trying to write some store procedures( PL/SQL )
    : : that
    : : : will select rows from my tables, and then pass then back to
    : my
    : : : JDBC application as result sets....Does anyone know how can
    I
    : : do
    : : : that? Do I need to use output parameters? Or Return
    : functions?
    : : : Any help or hint wourl be be gladly appreciate it.
    : : : Enrique
    : : : Thank you.
    null

  • Ref.Cursor Problem - URGENT

    Hi Friends,
    For my report ( calc.rdf ) ,
    I am passing two input parameters P_Client_ID, P_Plan_ID.
    In .rdf, I had a ref.cursor for selecting records based on
    two input parameters values.
    case1:
    P_client_ID = 'SRINI'
    P_Plan_ID = '3232'
    My report is generating the output for plan 3232.
    case2:
    P_client_ID = 'SRINI'
    P_Plan_ID = NULL
    My report is generating the output for all plans.
    case3:
    P_client_ID = 'SRINI'
    P_Plan_ID = '3232,3257,3259'
    My report is not generating any output here.
    Only blanck page i am getting.
    How can i pass multiple plans to ref.cursor at a time ?
    Note:
    I now, we cannot make Lexical references in a PL/SQL statement.
    Any other way to solve this problem ?
    Thanks for Help,
    srini

    I think that you work with 'static' ref cursor.
    From Oracle 8.1.5, we can use 'dynamic' ref cursors.
    With 'dynamic' ref cursor we can avoid the use of lexical parameters in Reports 3.0 / 6i.
    With 'static' ref cursor this is not possible in all cases.
    For example, if we need dynamic WHERE, we practically can't use 'static' ref cursor.
    Example for 'dynamic' ref cursor (dynamic WHERE)
    1. Stored package
    CREATE OR REPLACE PACKAGE report_dynamic IS
    TYPE type_ref_cur_sta IS REF CURSOR RETURN dept%ROWTYPE; -- for Report Layout only
    TYPE type_ref_cur_dyn IS REF CURSOR;
    FUNCTION func_dyn (p_where VARCHAR2) RETURN type_ref_cur_dyn;
    END;
    CREATE OR REPLACE PACKAGE BODY report_dynamic IS
    FUNCTION func_dyn (p_where VARCHAR2) RETURN type_ref_cur_dyn IS
    l_ref_cur_dyn type_ref_cur_dyn;
    BEGIN
    OPEN l_ref_cur_dyn FOR
    'SELECT * FROM dept WHERE ' || NVL (p_where, '1 = 1');
    RETURN l_ref_cur_dyn;
    END;
    END;
    2.2 Query PL/SQL in Reports
    function QR_1RefCurQuery return report_dynamic.type_ref_cur_sta is
    begin
    return report_dynamic.func_dyn (:p_where);
    end;
    Note that Oracle Reports 3.0 / 6i needs 'static' ref cursor type for building Report Layout.
    So, in package specification we must have both ref cursor types, static for Report Layout
    and dynamic for ref cursor query.
    Regards
    Zlatko Sirotic

  • Problems with JDBC-ODBC Driver

    Hello,
    I am trying to access a DSN on my windows with a dedicated DB driver of some company. so i used the JDBC-ODBC connector.
    when launching the java code, and debugging the problem i get the following error:
    DriverManager.getConnection("jdbc:odbc:priority32;UID=Manager;PWD=keren")
        trying driver--className=com.mysql.jdbc.Driver,com.mysql.jdbc.Driver@16caf43--
        trying driver--className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@66848c--
    *Driver.connect (jdbc:odbc:priority32;UID=Manager;PWD=keren)
    JDBC to ODBC Bridge: Checking security
    No SecurityManager present, assuming trusted application/applet
    JDBC to ODBC Bridge 2.0001
    Current Date/Time: Tue Aug 12 07:50:37 VET 2008
    Loading JdbcOdbc library
    Allocating Environment handle (SQLAllocEnv)
    hEnv=50338088
    Allocating Connection handle (SQLAllocConnect)
    hDbc=50338256
    Connecting (SQLDriverConnect), hDbc=50338256, szConnStrIn=DSN=priority32;UID=Manager;PWD=keren
    *Connection.getMetaData
    *DatabaseMetaData.getDriverName
    Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=6, len=300
    tabula.dll
    *DatabaseMetaData.getDriverVersion
    Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=7, len=300
    07.00.0000
    *DatabaseMetaData.getDriverName
    Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=6, len=300
    tabula.dll
    Driver name:    JDBC-ODBC Bridge (tabula.dll)
    *DatabaseMetaData.getDriverVersion
    Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=7, len=300
    07.00.0000
    Driver version: 2.0001 (07.00.0000)
    Caching SQL type information
    *Connection.getMetaData
    *DatabaseMetaData.getTypeInfo
    Allocating Statement Handle (SQLAllocStmt), hDbc=50338256
    hStmt=50339424
    Get type info (SQLGetTypeInfo), hStmt=50339424, fSqlType=0
    Number of result columns (SQLNumResultCols), hStmt=50339424
    value=15
    Get connection info string (SQLGetInfo), hDbc=50338256, fInfoType=10, len=300
    03.52.0000
    Fetching (SQLFetch), hStmt=50339424
    Column attributes (SQLColAttributes), hStmt=50339424, icol=1, type=2
    value (int)=12
    Column attributes (SQLColAttributes), hStmt=50339424, icol=1, type=3
    value (int)=129
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    CHAR
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=12
    Get integer data (SQLGetData), hStmt=50339424, column=3
    value=0
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    CHAR(1)
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=1
    Get integer data (SQLGetData), hStmt=50339424, column=3
    value=0
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    RCHAR
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=12
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    REAL
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=6
    Get integer data (SQLGetData), hStmt=50339424, column=3
    value=0
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    INT
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=4
    Get integer data (SQLGetData), hStmt=50339424, column=3
    value=0
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    UNSIGNED
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=4
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    TIME
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=10
    Get integer data (SQLGetData), hStmt=50339424, column=3
    value=0
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    DATE
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=11
    Get integer data (SQLGetData), hStmt=50339424, column=3
    value=0
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    DATE
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=9
    Get integer data (SQLGetData), hStmt=50339424, column=3
    value=0
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    DAY
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=4
    Fetching (SQLFetch), hStmt=50339424
    Get string data (SQLGetData), hStmt=50339424, column=1, maxLen=130
    DECIMAL
    Get integer data (SQLGetData), hStmt=50339424, column=2
    value=3
    Get integer data (SQLGetData), hStmt=50339424, column=3
    value=0
    Fetching (SQLFetch), hStmt=50339424
    End of result set (SQL_NO_DATA)
    *ResultSet.close
    Free statement (SQLFreeStmt), hStmt=50339424, fOption=1
    *ResultSet has been closed
    Get connection info (SQLGetInfo), hDbc=50338256, fInfoType=44
    int value=0
    Get connection info (SQLGetInfo), hDbc=50338256, fInfoType=121
    RETCODE = -1
    ERROR - Generating SQLException...
    SQLState(S1096) vendor code(0)
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Information type out of range
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbc.SQLGetInfo(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbcConnection.checkBatchUpdateSupport(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at WigsUpdate.main(WigsUpdate.java:25)
    getConnection returning driver--className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@66848c--what can be done?
    thank you very much

    HimberJack wrote:
    oh now i understand.
    i got a very unknown company which supplied the ODBC driver, but they dont have java driver...
    so I have nothing to do about it?The choices are find a different driver or use the one you have.
    The one you have doesn't do batches.
    Finding a different driver could involve the following.
    - Buying one from somewhere else
    - Pay someone to write one.
    - Write a driver yourself.
    All of those are somewhat dependent that the "unknown company" has an API that supports that. You (or someone) could also figure out the file format of the "unknown company" as well and then write one.

  • While using LT0G( Return to Stock from Delievry),item is Locked

    Hi All,
    We created an Intercompany STO, created delivery and since Storage Location was Warehouse Mnagaed created a TO for picking and di Goods Issue on that.Later it was realised some materials were wrongly included in delivery.So Goods Issue was reversed (VL09) and then while trying to reverse TO using LT0G we encountered a strange issue:
    1) One of the material included in delivery had delivered quantity as 108, during picking (TO creation) 70 units of the material got picked from one storage Bin and 38 from other Bin.
    Now in LT0G, i get the 2 line items created for this material however line item with only 38 quantity is active and allows to be returned to stock from Delivery, line item for remaining 70 units is locked and available quantity field is blank.Why it shows as locked? How can i unlock that? This is critical as we need to delete the picked material soon.
    Thanks,
    Anshul

    Select the locked item (set somehow the cursor on it), and click on "Log" button. What is the error message you get?
    Is the stock available?
    Isn't possible that someone already created the return TO for that item?
    LT0G is a troublesome transaction...(e.g. in case of stock determination group is set in material master it won't work; if not dynamic bin was used for picking you also may have problems, etc). Please check OSS notes there are many...
    You can try to process the item (try to create TO for that item) that is selectable and after that try LT0G again...
    (on selection screen of LT0G use "TO item view" radio button)
    remark:
    If you wants to delete the delivery you can do it w/o reversing the TO in LT0G. If the picking status is "C" you can delete the delivery and move the quant from 916 to normal storage type using LT01 / LT10...
    Regards,
    Csaba

  • JDeveloper + WebServices, RETURN multiple rows from pl/sql

    I need to return multiple rows from pl/sql procedure or function and publish it as a Web Service through JDeveloper.
    I try to use ref cursor, but then found that it is impossible to use ref cursor as a return value in Web Services.
    Please, help me to achieve result.

    Hello. I tried to make commands from article, but got errors
    "C:\Program Files\Java\jdk1.6.0_18\bin\java" -jar D:\oracle\Middleware\oracle_common\modules\oracle.webservices_11.1.1\wsa.jar -plsqlAssemble -appName Echo -sql wo -dataSource jdbc/OracleManagedDS -dbConnection jdbc:oracle:thin:@192.168.246.2:1521:data -dbUser syd/manager -style rpc -use encoded
    Error: Interface oracle.generated.wo: The class could not be loaded from the class path.

  • Cast error message when discovering ref cursor parameter from stored proced

    We are today using Microsoft's Oracle provider with some code from the old Data Application Block (from MSDN) to discover parameters from the stored procedures. This code uses the OracleCommandBuilder.DeriveParameters to get the parameters from the stored procedure and command.Parameters.CopyTo copies the discovered parameters into the command object.
    If I test with a simple function returning a ref cursor I get one parameter with type refCursor and ParameterDirection.OutPut. This is working fine as long we where using Microsoft's Oracle provider. But using Oracle ODP .NET I get the following error message on datadapter.Fill (I fill a dataset with the result from the reference cursor)
    Unable to cast object of Type 'Oracle.DataAccess.Client.OracleDataReader' to type 'Oracle.DataAccess.Types.OracleRefCursor.
    If I create a ref parameter manualy like this:
    OracleParameter myrefCursor = new OracleParameter();
    myrefCursor .OracleDbType = OracleDbType.RefCursor;
    myrefCursor .ParameterName = "myParameterName";
    myrefCursor .Direction = ParameterDirection.ReturnValue;
    and add it to the command object this is working OK. So it seems to be a problem with discovering ref cursor parameters from the database, other parameter types is OK.. I have compared the properties of my manual ref cursor parameter with the one discovered from the stored procedure, but I cannot see any difference. (I see the Value property has some values for the discovered one, but I have set this to DBNull.Value without any result)
    Any ideas why I get this error code? Is there any other code blocks I can use to discover the parameters? We send in params object[] with the different values into the helper class and the value is added to the parameter. (Se I don't need to set the data type etc for each parameter, I just need to have the correct order of the parameters)

    For accuracy's sake, just wanted to let everyone know that this is actually a bug. The correct bug number is 8423178.
    Christian
    Mark_Williams wrote:
    Just to follow-up on this issue...
    The bug has been closed as "not a bug" as it seems undocumented behavior was relied upon for this to work in earlier releases.
    Note from the documentation on DeriveParameters:
    "The output values of derived parameters return as .NET Types by default. To obtain output parameters as provider types, the OracleDbType property of the parameter must be set explicitly by the application to override this default behavior. One quick way to do this is to set the OracleDbType to itself for all output parameters that should be returned as provider types." (emphasis added)
    The issue, as you might already know, is that there is no corresponding .NET Framework Type for an Oracle Ref Cursor and the type is, therefore, set to Object. So, explicitly setting the type to OracleDbType.RefCursor should work.
    Regards,
    Mark

Maybe you are looking for

  • Install Fatal Error

    I'm encountering a fatal error when I attempt to install Expressions studio. I have the log if that helps. Tried uninstalling and reinstalling several times and keep getting the same fatal error message.

  • How can I recover my data from my hard drive

    About 2 weeks ago I was uploading pictures to my computer when it froze. I turned it off by holding down the power key, and started it up again. It hasn't gone past the apple screen and the spinning dial since. I have tried all the troubleshooting my

  • How to disable menu bar and dock when playing a full screen game? Like sims 4

    i play sims 4 on my MacBook pro and if I go to close to the bottom of the screen or the top the menu bar or dock pops up I was wondering if there is A program or a setting I can use to disable that while in something full screen or gaming

  • Need script to automate creation of AD sites,subnets and site links

    Hello, I have a requirement to create hundreds of sites and thousands of subnets in AD and also site links. I have an excel file with the details.  Can somebody help me with a vbscript/powershell script to automate this and create all the AD sites, s

  • TS1702 Error when trying to browse in iBooks. 1st gen iPad

    When trying to use the "browse" feature in iBooks, I get an error window saying "Cannot connect to iTunes." I have a 1st generation iPad. I've tried every suggestion I've found online, both through Apple and other forums. Nothing fixes the problem. A