DBMS_XMLGEN --Number of active cursors in increased in Exception block

Hi ,
We have a custom code that use DBMS_XMLGEN,the issue is when any exception happens the Number os active cusrors increse and when it happens in a lopp we hit 1000ORA-01000: maximum open cursors exceeded.
Although I close the context in the exception Block.
Below is sample code where I could replicate this:
Step1.Create a table
CREATE TABLE EMP(EMP_NO NUMBER,EMPNAME VARCHAR2(100));
Step2:
Create  a Procedure:
CREATE OR REPLACE PROCEDURE TEST_XMLGEN
AS
l_clob CLOB;
  l_ctx         dbms_xmlgen.ctxhandle;
  p_sql VARCHAR2(4000):='SELECT EMP_NO,,EMPNAME FROM EMP';--syntax error on purpose ,so that exception happens
  l_cursor_count NUMBER;
BEGIN
SELECT VALUE
           INTO l_cursor_count
           FROM v$mystat a, v$statname b
          WHERE     a.statistic# = b.statistic#
                AND b.name = 'opened cursors current';
        DBMS_OUTPUT.PUT_LINE ('open cursors place00' || l_cursor_count);
l_ctx := dbms_xmlgen.newcontext (p_sql);
SELECT VALUE
           INTO l_cursor_count
           FROM v$mystat a, v$statname b
          WHERE     a.statistic# = b.statistic#
                AND b.name = 'opened cursors current';
         DBMS_OUTPUT.PUT_LINE('open cursors place01' || l_cursor_count);
dbms_xmlgen.getxml (l_ctx,l_clob);
SELECT VALUE
           INTO l_cursor_count
           FROM v$mystat a, v$statname b
          WHERE     a.statistic# = b.statistic#
                AND b.name = 'opened cursors current';
         DBMS_OUTPUT.PUT_LINE ('open cursors place02' || l_cursor_count);
DBMS_OUTPUT.PUT_LINE('l_clob:'||l_clob);
dbms_xmlgen.closecontext (l_ctx);
SELECT VALUE
           INTO l_cursor_count
           FROM v$mystat a, v$statname b
          WHERE     a.statistic# = b.statistic#
                AND b.name = 'opened cursors current';
         DBMS_OUTPUT.PUT_LINE ('open cursors place03' || l_cursor_count);
EXCEPTION
WHEN OTHERS
THEN
SELECT VALUE
           INTO l_cursor_count
           FROM v$mystat a, v$statname b
          WHERE     a.statistic# = b.statistic#
                AND b.name = 'opened cursors current';
         DBMS_OUTPUT.PUT_LINE ('open cursors place04' || l_cursor_count);
dbms_xmlgen.closecontext (l_ctx);
SELECT VALUE
           INTO l_cursor_count
           FROM v$mystat a, v$statname b
          WHERE     a.statistic# = b.statistic#
                AND b.name = 'opened cursors current';
         DBMS_OUTPUT.PUT_LINE ('open cursors place05' || l_cursor_count);
END;
Step3: Execute above Procedure
If you look at the number of active cursor it is increased in exception block,I suspect this is what is causing issue with my program too.Any suggestions to solve this issue.
Thanks
Shefali

Did you mean this test:
declare
  ts timestamp;
  type tp_strings is table of varchar2(32767) index by pls_integer;
  t_strings tp_strings;
  t_tmp xmltype;
  t_nd dbms_xmldom.domnode;
  t_nl dbms_xmldom.domnodelist;
  t_clob clob;
begin
  t_clob := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
         || '<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="5000" uniqueCount="5000">';
  for i in 1 .. 5000
  loop
    t_clob := t_clob || to_clob( '<si><t>A' || to_char( i ) || '</t></si>' );
  end loop;
  t_clob := t_clob || '</sst>';
  t_tmp := xmltype( t_clob );
  t_strings.delete;
  ts := systimestamp;
      select str
      bulk collect into t_strings
      from xmltable( xmlnamespaces( default 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' )
                   , '/sst/si' passing t_tmp
                   columns str clob path 't'
  dbms_output.put_line( systimestamp - ts );
  dbms_output.put_line( t_strings.count() || ' ' || t_strings( t_strings.first )  || ' ' || t_strings( t_strings.last ) );
  t_strings.delete;
  ts := systimestamp;
      select /*+ NO_XML_QUERY_REWRITE */ str
      bulk collect into t_strings
      from xmltable( xmlnamespaces( default 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' )
                   , '/sst/si' passing t_tmp
                   columns str clob path 't'
  dbms_output.put_line( systimestamp - ts );
  dbms_output.put_line( t_strings.count() || ' ' || t_strings( t_strings.first )  || ' ' || t_strings( t_strings.last ) );
  t_strings.delete;
  ts := systimestamp;
      t_nd := dbms_xmldom.makenode( dbms_xmldom.getdocumentelement( dbms_xmldom.newdomdocument( t_tmp ) ) );
      t_nl := dbms_xslprocessor.selectnodes( t_nd, '/sst/si/t/text()', 'xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"' );
      for i in 0 .. dbms_xmldom.getlength( t_nl ) - 1
      loop
        t_strings( i ) := dbms_xmldom.getnodevalue( dbms_xmldom.item( t_nl, i ) );
      end loop;
  dbms_output.put_line( systimestamp - ts );
  dbms_output.put_line( t_strings.count() || ' ' || t_strings( t_strings.first )  || ' ' || t_strings( t_strings.last ) );
end;  

Similar Messages

  • Why do the number of active JMS connections increase?

    <strong>Problem</strong>
    - Number of active JMS connections and current JMS messages increases until the Weblogic instances crash with an OutOfMemory exception
    <strong>Setup</strong>
    - Weblogic v9.2.3, Cluster with 4 Nodes
    - A JMS Message is sent from a MDB in Weblogic to a distributed queue which has a member on each of the 4 Weblogic nodes. The session is created as follows session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE), the message delivery mode is set programmatically to persistent and the delivery mode override of the queue setup is set to persistent too
    - Standalone JMS client processes: each one is attached to <strong>all</strong> 4 nodes. Each one uses a unique JMS message selector so that we have more than one queue consumer for one queue but every message is exactly dedicated to one queue consumer. We us weblogic.jar for the clients.
    - Use of Weblogic auto reconnect feature. JMS client code:
    Connection connection = this.connectionFactory.createQueueConnection();
    final WLConnection wlconnection = (WLConnection)connection;
    wlconnection.setReconnectPolicy(JMSConstants.RECONNECT_POLICY_ALL);
    wlconnection.setTotalReconnectPeriodMillis(-1);
    wlconnection.setReconnectBlockingMillis(-1);
    <strong>Remarks and Questions</strong>
    - There are no pending JMS messages which is good
    - In our setup, each JMS client is connected to all 4 nodes as the messages are not distributed to all nodes: if a message is put to Queue A but the client is only connected to Queue B, the message is NOT transfered from Queue A to Queue B. We set the parameter "Forward Delay" to 5 seconds with no effects. Is this the normal behavior?
    - Not all JMS clients are visible in the Weblogic console under JMS Services -&gt; JMS Servers -&gt; [Server] -&gt; Monitoring -&gt; Active Connections. Which one are visible? Which one are not visible? There are also clients where the number of connections is not zero but stays constant; we know that as several independent clients on different hosts are started and the IP adress is visible in the Weblogic console. Why....?
    - What reasons can lead to increasing connections? Is this due to client or server problems? Do we have to acknowledge the message in the onMessage(Message) method of the client JMS consumer? So far as I know, we don't have to.
    - Are the increasing number of current messages due to the increasing number of JMS connections?
    - May the RECONNECT_POLICY_ALL policy produce this problem?
    Any hint is appreciated.
    Peter
    Edited by: pkeller on 23.10.2008 17:08

    To answer the question about the forwarding of messages from one queue to another myself: As mentioned at http://forums.bea.com/thread.jspa?threadID=400000611, the forwarding for queues does only work if all queue consumers are attached to the same queue. This means that our setup is OK.
    But the main question is still unanswered: why do the number of active JMS connections increase? I forgot to mention that
    - all messages arrive at the clients and that no exceptions are visible in the log
    - if you kill the client, the connections are still visible in the Weblogic console!?
    Please help as this problem is very urgent.
    Peter
    Edited by: pkeller on 24.10.2008 09:06
    Edited by: pkeller on 24.10.2008 09:10

  • Ref cursor in exception block

    Hi all.. I have a stored procedure that needs to return a records to Crystal Report.
    I'm using an outpur parameter of type cursor.
    In the proc, I am selecting the data from a table based on the input criteria and inserting into a GTT table,
    if so, retrieve and store in the table and generate and throw output to CR.
    if it is not returning any data i should raise exception and throw the related message to CR.
    But in my proc even though it wont insert data into table b going inot next statements where it should not go.
    create or replace procedure a(a1 varchar2,ref_cur out pkg1.cru)
    as
    cnt number;
    begin
    insert into b
    (select * from a where a.col=a1);
    commit;
    open ref_cur for
    select a.col from a;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR (-20001, SQLERRM);
    WHEN NO_DATA_FOUND THEN
         open ref_cur for
    select 'No Data Found' col from dual;
    end;
    1.please suggest wherer to raise exception when "select * from a where a.col=a1" doesn't return any value.
    2. Can ref cursor be used in exception block.
    if i use condition like
    after the insert statement
    select count(*) into cnt from b;
    if cnt=0 then
    raise NO_DATA_FOUND;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR (-20001, SQLERRM);
    WHEN NO_DATA_FOUND THEN
         open ref_cur for
    select 'No Data Found' col from dual;
    please suggest any other way to handle
    Thanks in advance

    First and foremost some fundamental things:
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR (-20001, SQLERRM);
    WHEN NO_DATA_FOUND THEN
    open ref_cur for
    select 'No Data Found' col from dual;
    end;1. You can not declare WHEN OTHERS before any other EXCEPTION. You can not compile this. Here you have declared WHEN OTHERS first then NO_DATA_FOUND and it is erroneous.
    2. This is not the way you want to handle the WHEN OTHERS exception.
    WHEN OTHERS_
    http://tkyte.blogspot.com/2008/06/when-others-then-null-redux.html
    http://tkyte.blogspot.com/2007/03/dreaded-others-then-null-strikes-again.html
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/toc.htm

  • Increased maximum number of open cursors

    I'm using JDBC with oracle. And I need to send many transactions to database.
    I use Statement.executeQuery("INSERT INTO ..............") and so on!
    But after 300 transaction Oracle send me an error that "increased maximum number of open cursors." How to increase the max number of that cursors or how to close them??
    Thanks in advance!

    1. Use, PreparedStatement instead of Statement.
    2. Use addBatch() and executeBatch() methods.
    3. Don't create statement objects in a loop, just create one object outside the while (or for) loop and use the same object again and again. Most probably the problem may be due to creating excessive object in a llop.
    Hope this helps.
    Sudha

  • Question about trigger to check the number of open cursors

    Hello.
    I wonder if it is possible to create a trigger that fires when the number of open cursors in a database becomes larger than a certain number. What kind of trigger and how would it be?
    If it were possible the trigger would write traces with the timestamp of the event.
    I would also like some pl/sql tester that would increase the number of open cursors so that I could check the trigger.
    Thanks in advance.

    Satish Kandi wrote:
    OPEN_CURSORS is a value per session and not for the entire database. So if your cron job is looking for a global cumulative value of open cursors to occur in a single session, it won't find any such sessions.
    Is it the case?Yes, I am afraid it is.
    I am sorry but I don't unsertand what you are telling me: doesn't "select count(*) from v$open_cursor" count the number of open cursor for all sid columns in the view?
    The cron launches a scripts that connects to the database via sqlplus whereas there is a java application (several threads without connection pooling) that connects to the database via jdbc and that causes the problem once in 5 months (to say something).
    Thanks again.
    Edited by: fsanchezherrero on Jul 3, 2009 12:28 PM
    Edited by: fsanchezherrero on Jul 3, 2009 12:36 PM

  • 'number of open cursors exceeded' exception - 10.3.1

    Hi All,
    We have may DynamicSQL statements fired from our processes due to which we are getting 'number of open cursors exceeded' exception. We don't want to increase the limit of the maximum open cursors. Is there any way to close the cursors explicitly in 10.3.1?
    I am aware that when the iterator fetches the last result the cursor gets closed (in the case of any select query) but we have faced the same issue once/twice in the insert query also, is it because we have fired one insert after the other immediately? How much time does a cursor takes to close (implicitly) in the case of insertion of data?
    Thanks in advance..
    Edited by: GBP on Jan 5, 2011 4:07 AM

    Hi,
    Please see my post: Re: Cursor closing using DynamicSQL.executeQuery
    Hope this helps,
    Ariel

  • ADE number of activation using single Adobe id

    hi,
       we are getting questions from clients regarding the number of activations for a single Adobe id. User manual says, 6 PCs and 6 devices are allowed with a single Adobe Id, and an addtional permission every year. but it also says if the limit exceeds then a user can contact adobe support to get more permissions. My question is " what would be a reason for the customer service of Adobe to grant a consumer more devices, when they contact  them?". can anyone answer this question please?
    regards,
    Roger

    Since removal of activation information on a device, and then reauthorization, uses up 2 activation counts, the most common cause for running out of activation is mistaken deactivations - tech support notes this and increases the activation allowance to account for this.

  • Errormessage: "Number of activations exceeded"  though I only use 2 devices.

    errormessage: "Number of activations exceeded"  though I only use 2 devices.
    Thank your for helping me with this issue.
    I had to reset my mobile phone and my tablet and now this message appears on my mobile phone:
    "Number of activations exceeded"  though I only use 2 devices.
    I use Mantano reader premium.
    Kind regards,
    Regula

    Thank you Dominic, unfortunately your link does not give me the exact help
    what to do next.There are only some general links.
    Somewhere in the forum I found this:
    . If you reach the limit,
    contact Customer Service to increase your allowable activations. Please
    let us know if these will help in resolving your issue.
    Is there an emailadress to contact, sinI am at work and can't chat.
    Thank you and kind regards,
    Regula
    2014-02-17 7:41 GMT+01:00 Dominic Michael <[email protected]>:
        Re: errormessage: "Number of activations exceeded" though I only use
    2 devices.  created by Dominic Michael<http://forums.adobe.com/people/Dominic+Michael>in *Adobe
    Digital Editions* - View the full discussion<http://forums.adobe.com/message/6127568#6127568

  • Report showing the number of active users in the system

    All,
    There is a standard SAP report which shows the number of active users in the system (output same as AL08).
    Does anyone remember this?
    Cheers,
    Bidwan

    Hello Bidwan, 
    Are you talking about the report RSUSR000?
    Regards.
    Ruchit.

  • How to get highest number of open cursors within the current calendar day

    Hi all ,
    i need to know how to get the highest number of open cursors within the current calendar day.
    Thanks ,

    823030 wrote:
    the issue is my customer is getting the error ORA-01000: maximum open cursors exceeded and we need an sql statment that gets the following values :
    -highest number of open cursors experienced in the current calendar day.
    -current open cursors
    -and maximum open cursorsThis error is rare. It happens when
    a) the value of the open cursor parameter is set extremly low (default is something like 1000). Low would be something like 10.
    b) <strike>you have many concurrent users(=sessions) and </strike>the application does not use bind values
    In this case each select will open a new cursor, instead of reusing it.
    c) you have a select that opens a cursor for each line. This can happen with a statement where you have the CURSOR keyword somewhere in the select or where clause. Those cursors will be closed when the select is finished. But during the run time of the select, all cursors stay open.
    To track the number of "open cursors" during the day you would need to implement some monitoring. Maybe based on the view that was already mentioned.
    Edited by: Sven W. on May 16, 2011 2:30 PM - since the parameter is on session level, other open cursors should not influence it much.

  • Check the number of active users of oc4j in EBS

    Hi,
    I often see a recommndation of sizing jvm's to 1 per 100 active users. How can I find the number of active users currently using a jvm in EBS. We have 4 apps servers and 1 of apps servers also runs OBIEE with it's own jvm.
    I can find out from a unix command prompt counting establish connections to the port but I like to know if there's a better way to find the number of active users using the jvm's
    Thanks
    Mike

    Hi,
    To find the number of active user session on each of the application servers from a unix command line. I would find the port that Apache was listening on eg 8100. The use the following command on each of the apps servers
    netstat -an | grep 8100 | grep -i est | wc -l
    This gives a rough idea of how many active connections are established to the apps server. But I would really like to find how many users are actively using o4cj.
    If you are using forms in socket mode again, you can grep on the forms listening port number to find how many active forms users are connected.
    I can also see how many active connections are in the oc4j established to the database using lsof. Find the process id for oacore jvm.
    lsof -p PID
    But I'm sure there's a better and more accurate way of find active users of o4cj, specifically oacore.
    Thanks
    Mike

  • Getting the number of active connections in a connection Pool

    Hi,
    I have an application deployed on jboss. DB used is db2. For monitoring purpose i need to get the number of active and idle connections at any point of time. I am trying to use commons-dbcp jar to get this data using BasicDataSourceClass. Following is the piece of code.
    Context initialContext;
    try {
         initialContext = new InitialContext();
         DataSource ds = (DataSource) initialContext.lookup(myjndiname);
         logger.info("************CONNECTION POOL DATA->" + ds.getClass().getName() + "************" + ds.getClass() + "**************");
         BasicDataSource bds = (BasicDataSource) datasource;
              logger.info("************CONNECTION POOL DATA-> ACTIVE CONN=" + bds.getNumActive() + " IDLE CONN=" + bds.getNumIdle() + " INIT SIZE=" + bds.getInitialSize());
    catch (NamingException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
    This code gave a class cast exception at the point datasource is cast to BasicDataSource. The class name returned by ds is WrapperDataSource. I have few queries on this:-
    1. What configurations do i need so that datasource returned by InitialContext is BasicDataSource? FYI i tried to add the BasicDataSourceFactory in db2-ds.xml. But it still didnt work
    2. Is there any other way to find the number of active connections in a connection pool? I dont want any server specific solution.
    Pls help.
    Thanks

    user13642196 wrote:
    Hi,
    I have an application deployed on jboss. DB used is db2. For monitoring purpose i need to get the number of active and idle connections at any point of time. I am trying to use commons-dbcp jar to get this data using BasicDataSourceClass. Following is the piece of code.
    Context initialContext;
    try {
                 initialContext = new InitialContext();
                 DataSource ds = (DataSource) initialContext.lookup(myjndiname);
                 logger.info("************CONNECTION POOL DATA->" + ds.getClass().getName() + "************" + ds.getClass() + "**************");
                 BasicDataSource bds = (BasicDataSource) datasource;
              logger.info("************CONNECTION POOL DATA-> ACTIVE CONN=" + bds.getNumActive() + "  IDLE CONN=" + bds.getNumIdle() + "   INIT SIZE=" + bds.getInitialSize());
    catch (NamingException e) {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
    }This code gave a class cast exception at the point datasource is cast to BasicDataSource. The class name returned by ds is WrapperDataSource. You can only cast an object to an interface it implements or to a class it extends (directly or indirectly).
    I have few queries on this:-
    1. What configurations do i need so that datasource returned by InitialContext is BasicDataSource? FYI i tried to add the BasicDataSourceFactory in db2-ds.xml. But it still didnt workhttp://commons.apache.org/dbcp/api-1.2.2/org/apache/commons/dbcp/package-summary.html#package_description

  • How to know the number of Active users logged in to a Essbase  Application?

    Hi,
    Is there way to capture/log the number of active users who have logged into a particular Essbase application at a given time.
    In Essbase or in Shared services?
    I know we can see the EAS-Edit Sessions shows the actively logged-in users, then we can sort on the application/database & manually count the number.
    Is there a way to capture it in a log at a given time on a regular basis. Any MAXL or Shared services feature?
    Appreciate your thoughts.
    Thanks,
    Ethan.

    You could use maxl .
    display user all;
    there will be a column called "logged in" which will display true/false for the users
    but that will just show if they are logged into the server and not the application
    You can also use use display session
    display session all;
    or
    display session on application sample;
    which should show what you are after.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • How do I reset the number of activations on Visio 2003 after getting a "too many activations" message?

    I just installed Visio 2003 on a PC, and got the "we can't activate this app via the internet because you've installed it too many times" message. I went back to phone activation, but, of course, that's no longer available for this product.
    How do I get the number of activations reset? Apparently you used to be able to do this by calling Microsoft, but what's the number to call? Or is there another way to do it?
    I'm probably going to need to do it for my copy of Office 2003 also.

    Hi,
    Microsoft has ended support for Office 2003 on April 8, 2014. This change will affect your software updates and security options.
    Please contact your local customer service. Explain to the service (Human being) that you can’t activate Visio 2003 and the error message is “we can't
    activate this app via the internet because you've installed it too many times”.
    You can find
    your local custom support number on the link below.http://support.microsoft.com/gp/customer-service-phone-numbers/en-us
    Hope it can be helpful.

  • I am trying to install CS2 on my new computer but it is not accepting my serial number or activation number?

    This is an old version of CS2 but my old computer died and I would like to be able to use the CS2 on my new computer.  My serial number and activation number are not accepted and need an authorization code.
    Thank You!

    This will probably help:
    Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3

Maybe you are looking for

  • Sharepoint 2013 runtime error: Server Error in '/' Application.

    Morning Ladies and Gentlemen, I am an Intern in a mining company that decided to use sharepoint as their intranet system. Everything was going fine upto yesterday. I don't know if this might be the source of the problem, but after my boss asked for t

  • Lost program display after using ext display

    I am away from home and only have my MBPro. I home I have an external display and was running Google Earth on the external. Now I start the program and it is not showing on the laptop. Is there a command that will move the program to the active scree

  • Error when creating or updating command syntax in an ODI procedure

    Hi - I'm new to ODI and trying to create/update a procedure. It doesn't seem like it matters whether the sql statement is correct or not a generic message always seems to be displayed when the command syntax is modified. On a different machine, this

  • "No receiver is entered" in SWEL when triggered via program.

    Hi WF experts, I'm currently working on a workflow with Z business object. My WF contains a "wait for event" step. When I launch my WF directly from SWDD. It works (I verify in SWEL and i find receiver data in the details, but when i trigger the even

  • Mysterious "Other" User at Login Window????

    Hi folks, Ive just updated my old iMac G3 to Tiger 10.4.3 (from OS9) and connected it to my Powermac G5 (10.4.3) via a network cable. The thing is for some reason when the iMac boots up the login window shows the correct user (my wife) but also shows