Something about  open cursor .

Guys ,  I need an advice, I'm doing the following code, but I´n not sure  if it can work or could be very slow , the thing is that que ti_referenc could have more than 1 million entries , what else is possible to do ?
      LOOP AT ti_referenc.
        OPEN CURSOR WITH HOLD cursor1 FOR
         SELECT * FROM zpf_cob_doc_ext
          WHERE referencia = ti_referenc-ref.
        FETCH next cursor cursor1
        APPENDING CORRESPONDING FIELDS OF TABLE it_zpf_cob_doc_ext
        PACKAGE SIZE p_commit.
        CLOSE CURSOR cursor1.
      ENDLOOP.
thank you  a lot.

hi,
You can even add additional code as below ..
OPEN CURSOR WITH HOLD cursor1 FOR
SELECT * FROM zpf_cob_doc_ext
WHERE referencia = ti_referenc-ref.
DO.
FETCH next cursor cursor1
APPENDING CORRESPONDING FIELDS OF TABLE it_zpf_cob_doc_ext
PACKAGE SIZE p_commit.
IF sy-subrc <> 0.
CLOSE CURSOR cursor1.
EXIT.
ENDIF.
ENDDO.

Similar Messages

  • Confused about Open Cursors :(

    Hi all,
    i need some clarification on this issue, i've read throught the documentation and i'm a bit confused.
    I'm using 10.1.0.2
    select sum(value)
    from v$statname sn,
    v$sesstat st,
    v$session s
    where sn.statistic# = st.statistic#
    and st.sid = s.sid
    and sn.name = 'session cursor cache count'
    The result of the above query is 4926, meaning i have 4926 CLOSED cursors in the session cursor cache.
    select count(1)
    from v$open_cursor
    The result of the above query is 16968, meaning i have 16968 cached cursors
    So there are two distinct cursor Caches ?
    now lets look at other statistic
    select sum(value)
    from v$statname sn,
    v$sesstat st,
    v$session s
    where sn.statistic# = st.statistic#
    and st.sid = s.sid
    and sn.name = 'opened cursors current'
    this one gives me 12212 , so i have 12212 opened cursors (NOT CACHED , REALLY OPENED CURSORS ...is this correct???)
    I suspect that my applications are not closing resultsets (java build application, deployed in oracle application server, database connections in pooled connection) ... so i'm trying to help my developers to find the potencial bug in application.
    How can i get the SQL from OPEN cursors ???
    V$open_cursor gives me SQL from CLOSED cached cursors ...
    Best Regards
    Rui Madaleno

    Hi,
    >>this one gives me 12212 , so i have 12212 opened cursors (NOT CACHED , REALLY OPENED CURSORS ...is this correct???)
    For your instance, yes because you use the sum(value) aggregate function. But I think that the best is get this value per session.
    select count(1) from v$open_cursor
    v$open_cursor shows cached cursors, not currently open cursors, by session. If you're wondering how many cursors a session has open, don't look in v$open_cursor. It shows the cursors in the session cursor cache for each session, not cursors that are actually open. To monitor open cursors, query v$sesstat where name='opened cursors current'. This will give the number of currently opened cursors, by session:
    select a.value, s.username, s.sid, s.serial#
    from v$sesstat a, v$statname b, v$session s
    where a.statistic# = b.statistic#  and s.sid=a.sid
    and b.name = 'opened cursors current';
    >>I suspect that my applications are not closing resultsets (java build application, deployed in oracle application server, database connections in pooled connection)
    In this case, you need to monitor you application. If want, you can use the OEM Database Console and go to [Top Sessions | Session Details] link, or to use this SQL above.
    By the way, do you are getting ORA-1000 errors ?
    If so, set the OPEN_CURSORS parameter high enough that you never get an ORA-1000 during normal operations.
    Cheers

  • TS2834 I've been using the mail app that came with my Mac for over a year. Out of the blue, it will not open and keeps saying "Mail cannot open because of a problem" and something about not being compatible ??? Help! I miss my mail

    I've been using the mail app that came with my Mac for over a year. Out of the blue, it will not open and keeps giving me an error like "Mail cannot open because of an error and something about it not being compatible. Please help! I miss my mail

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V).
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • When I clicked on Firefox, the update bar started but when it stopped Firfox would not open. The blue screen of death popped up and said something about a new installation. We restarted the computer and now Firefox will not open. Help!

    When I clicked to open Firefox the update bar appeared and an update loaded. Usually when this happens Firefox will open up when the update is finished. This time it did not open. when I clicked on the icon again the blue screen opened and said something about a new installation and if this was the first time you have seen this screen restart your computer and try again. I restarted the computer and when I clicked on the Firefox icon the "hour glass" would appear like it was trying to open but it never would open. I don't know what else to do.

    See below -- the way I asked the question the first time may not be clear. This post was a goof but I can't figure out how to delete it

  • I downloaded newest itunes version and it would not install properly and now i can't open it. i have removed and reinstalled several times. i get error 7 (windows error 126) something about apple mobile device failed to start. anybody having this problem.

    i downloaded newest itunes version and it would not install properly and now i can't open itunes. i have removed and reinstalled several times. i get error 7 (windows error 126) something about apple mobile device failed to start. what can i do to fix this problem besides restoring system to an earlier date

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • Can't open pdf. files something about patch package

    Can't open PDF files something about patch package verification.error.

    I am having the same issue.  Unable to open ANYTHING related to adobe (PDF, downloads), as well as unable to delete and reinstall or even change or correct. 

  • 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

  • I can't get the leapfrog connect to open.  It says something about the Testgen fonts.  Please help.

    I need help with the leapfrog connect application.  It won't open and it keeps saying something about the font Testgen.  Please help me if you can.

    Considering that the "Most recent updates" link on the Leapfrog Connect homepage is dated November 2009, I wouldn't hold out too much hope that your software is compatible with Lion, released in July 2011.

  • I recently added Maverick to my Mac Safari and downloaded a book to Digital Editions 2 on my computer. I downloaded the book to my Kobo but Kobo will not allow me to open the book. It says it belongs to Digital Editions and says something about my passwor

    I recently added Maverick to my Safari and downloaded a book from the library to Digital Editions 2 on my computer. When I downloaded the book to my Kobo, Kobo would not allow me to open it saying it was owned by Digital Editions and saying something about my password. Do I need to change to Digital Editions 3??

    Hey! I had the same problem you did just today when I was trying to get my second iPhone to sync. What you need to do with music or anything extra that you doing you have to creat a second playlist or picture or anything that you would like to use, so that you can add to the second device that you are going to be using. I am not sure if that will help but it helped me out a lot!! Good luck!

  • When I down load books, can I read them on my iPad and iPhone? I went to open a book on my phone but I got a message that aid something about the bill already associated with an appleid. I use the same id for both devices.

    When I down load books, can I read them on my iPad and iPhone? I went to open a book on my phone but I got a message that aid something about the bill already associated with an appleid. I use the same id for both devices.

    All I can suggest is that you open that file on the MBA and save it as a new file, then see if you can open the new one on the iMac.

  • Firefox will not open on my Mac, it says something about security settings but I don't know where to go

    it says something about security settings

    The button would be on your iPod version of Skype, not the computer version. They are not the same.

  • Oracle and "Maximum open cursors exceeded"

    Hi,
    I am using Weblogic 7.0sp2 with Oracle 9.2.0. Since we are using manual JTA
    transactions and the 9.2 drivers are buggy in that respect, we are using the
    9.0.1 thin drivers delivered with weblogic.
    The problem I have is that after a while, we get the now classic "Maximum open
    cursors exceeded" error on connections from our connection pool (used through
    a
    TX datasource). I have of course checked all our JDBC code and it is fine. We
    do not leave any statement/connection open. In fact, I am certain that the
    problem is not caused by our applicative code.
    The reason I am so positive is that the numbers of open (cached) cursors is
    growing, even though there is no activity on our application (I mean no
    activity at all). The number of cursors is regurlarly increasing by one
    every 5 minutes until it reaches the maximum allowed for a session.
    I have listed the statements corresponding to the opened cursors (they
    do not belong to our code, as you might have guessed):
    SELECT sysdate, user from dual
    select longdbcs from javasnm$ where short = :1
    select longname from javasnm$ where short = :1
    As you can see, there are only three different statements. You can get
    the statements from the system view v$open_cursor for a given session
    but it will only give one row per different statement. If you want to know
    the # of opened cursors in your cursor, use v$sesstat with statistic# = 3
    (opened cursor current).
    I suspect something is wrong in the connection testing done by weblogic
    for the pool (I have activated test on reserved connections and test table
    name is "dual") that leaves a resultset/statement behind. What is weird
    though is that the refresh period is still 0 (not 5 minutes as you would
    expect from the cursor growth rate...).
    I would not say that it is an Oracle bug (as stated in some BEA FAQ I read)
    since our application JDBC code does not exhibit the same problem. The
    problem appeared with recent version of WebLogic for which the session
    cursor cache is enabled, I suppose for performance reasons - this
    is set by isssuing "ALTER SESSION SET SESSION_CACHED_CURSORS = ...".
    Talking about this, does anybody know to which value WebLogic sets this
    parameter when intializing the connection (this is neither
    documented/configurable)?
    Up to now, I have come up with possibly two workarounds, neither of which
    is satisfying:
    - resetting the pool from time to time
    - issuing "ALTER SESSION SET SESSION_CACHED_CURSORS = 0" when I get a
    connection from the pool. I have not tested this one personally (read
    in a newsgroup that someone else did successfully) but it is supposed
    to reset the cursor cache that is causing the trouble.
    Any help will be greatly appreciated,
    Regards,
    Thierry.

    Thierry Rouget wrote:
    Hi,
    I am using Weblogic 7.0sp2 with Oracle 9.2.0. Since we are using manual JTA
    transactions and the 9.2 drivers are buggy in that respect, we are using the
    9.0.1 thin drivers delivered with weblogic.
    The problem I have is that after a while, we get the now classic "Maximum open
    cursors exceeded" error on connections from our connection pool (used through
    a
    TX datasource). I have of course checked all our JDBC code and it is fine. We
    do not leave any statement/connection open. In fact, I am certain that the
    problem is not caused by our applicative code.
    The reason I am so positive is that the numbers of open (cached) cursors is
    growing, even though there is no activity on our application (I mean no
    activity at all). The number of cursors is regurlarly increasing by one
    every 5 minutes until it reaches the maximum allowed for a session.
    I have listed the statements corresponding to the opened cursors (they
    do not belong to our code, as you might have guessed):
    SELECT sysdate, user from dual
    select longdbcs from javasnm$ where short = :1
    select longname from javasnm$ where short = :1
    As you can see, there are only three different statements. You can get
    the statements from the system view v$open_cursor for a given session
    but it will only give one row per different statement. If you want to know
    the # of opened cursors in your cursor, use v$sesstat with statistic# = 3
    (opened cursor current).
    I suspect something is wrong in the connection testing done by weblogic
    for the pool (I have activated test on reserved connections and test table
    name is "dual") that leaves a resultset/statement behind. What is weird
    though is that the refresh period is still 0 (not 5 minutes as you would
    expect from the cursor growth rate...).
    I would not say that it is an Oracle bug (as stated in some BEA FAQ I read)
    since our application JDBC code does not exhibit the same problem. The
    problem appeared with recent version of WebLogic for which the session
    cursor cache is enabled, I suppose for performance reasons - this
    is set by isssuing "ALTER SESSION SET SESSION_CACHED_CURSORS = ...".
    Talking about this, does anybody know to which value WebLogic sets this
    parameter when intializing the connection (this is neither
    documented/configurable)?
    Up to now, I have come up with possibly two workarounds, neither of which
    is satisfying:
    - resetting the pool from time to time
    - issuing "ALTER SESSION SET SESSION_CACHED_CURSORS = 0" when I get a
    connection from the pool. I have not tested this one personally (read
    in a newsgroup that someone else did successfully) but it is supposed
    to reset the cursor cache that is causing the trouble.
    Any help will be greatly appreciated,
    Regards,
    Thierry.Hi. We don't make those queries either. I suspect they are internal to the
    oracle driver. One thing you can try is to set the size of the pool's
    statement cache to zero. Oracle will retain cursors for every statement we
    cache. The alternative is also to tell the DBMS to allow a given session
    more cursors.
    Joe

  • What a mess !! : ORA-01000: maximum open cursors exceeded

    I have read a lot of article about this error
    I m also having this problem with 8.1.6.0 or 8.1.6.1 oracle db ( and classes112 jdbc drivers ) and my application
    I have checked that I close every statment,preparedstatment,recordset and connection ( connections are closed every 30 sec by a dbpool object ) objects when I have finished to do the job but I m still having this error.
    In fact it seems that with theses oracle releases, the statment,preparedstatment and recordset.close have no effect on cursors.
    looks like that it clears the cursors only when you close the connection.
    So anyone here know what version of oracle and jdbc drivers correct this bug ? 8.1.6.2 ? 8.1.7.0 ? classes12 drivers ?
    oracle 8.1.5.0 seems to work fine I have monitored the cursors activity with select user_name, sql_text from v$open_cursor; and they are opened and closed correctly ( statment.close do the job.. )
    I m quite lost. Anyone have some info to share with me about this issue ?
    Thanks a lot for any response

    I've dealt with this problem too. Oracle says that it is a jdbc implementation problem. We came accross this problem when running reporting/high volume programs even after every jdbc object was dealt with(.close(), =null..etc). Something about internally spawn cursors not being dealt with by the DB. Apparently this was dealt with in the newest release of classes12.zip but we found that we still had excess cursors. We set our open_cursors variable to over 400(default is lower than 50) . Doing a forced conn.rollback() every time the connection was returned to the pool seemed to help too.
    Jamie

  • Cannot figure out why "ORA-01000 Maximum open cursors" is shown...

    Hello there ...
    I am programming a PL/SQL Code that is throwing 0RA-01000 Maximum Open Cursors Exceeded.
    Having already read quite a lot about ORA-01000 errors, I know I should be closing cursors, and have already tried setting OPEN_CURSORS parameter to a high number (1000).
    I declared a lot of procedures in my pl/sql, each of which uses one cursor since i am working with a non-Oracle table linked by ODBC ... and each procedure sometimes does thousands of inserts -- but all WITHIN the explicit cursors. The explicit cursors are not declared within each loop.
    I already checked the code many times, and made sure all open cursors are closed. In addition, I also verified the numberopen cursors generated by the PL/SQL by running the following SQL after every procedure i run... and outputting it... and it appears the value just keeps on increasing, even though I had explicitly closed all the cursors in all the earlier procedures.
    What is funny is that the most number of cursors reported by the code below only hits 150+ cursors. Nowhere near the 1000 open_cursors limit per session.
    select a.value into strtxt --, b.name        
            from v$mystat a, v$statname b
            where a.statistic# = b.statistic#
            and a.statistic#= 3;When I run the procedures separately though, all the procedures run smoothly (even when I had not yet updated the open_cursors parameter).
    I was thinking of the following, but maybe you have some other ideas?
    Does this have anything to do with my procedures not being stored procedures?
    Or should i be committing records within my procedures instead of out of it?
    I really have run into a wall and would really appreciate any tips or helps on this. Thanks in advance!
    My basic pl/sql code looks like below. I did not give the actual details cause it will be too long (up to 5000 lines).
    DECLARE
    PROCEDURE proc1
    IS
        CURSOR cur_hca
           is
               select ...from..where;
       TYPE cur_hca_fetch
            Is TABLE OF cur_hca%ROWTYPE
                INDEX BY PLS_INTEGER;
        temp_collect cur_hca_fetch;
    BEGIN
       open cur_hca;         --cur_hca is the cursor name.
                                      --i use exactly the same cursor name in the other procedures
          loop
             fetch cur_hca bulk collect into temp_collect LIMIT 1000;
             exit when temp_collect.count=0
             for indx in 1 .. temp_collect.count
                loop
                  ...run some sql
                end loop;
          end loop;
      close cur_hca;
    END proc1;
    PROCEDURE proc2   --almost the same as above the only changes are the query for the
                                 -- cursor and the sql that happens for each record
    IS
    BEGIN
       open cur_hca;         --cur_hca is my cursor name
          loop
          end loop;
      close cur_hca;
    END proc2;
    ... up to 40 other very similar procedures
    BEGIN
       proc1;
       commit;
       select a.value into strtxt
            from v$mystat a, v$statname b
            where a.statistic# = b.statistic#
            and a.statistic#= 3;
      DBMS_OUTPUT.PUT_LINE('Number of Cursors After STATUSproc1: ' || strtxt); 
       proc2;
       commit;
       select a.value into strtxt
            from v$mystat a, v$statname b
            where a.statistic# = b.statistic#
            and a.statistic#= 3;
       DBMS_OUTPUT.PUT_LINE('Number of Cursors After STATUSproc2: ' || strtxt); 
       ... 40 other procedures
    END;Edited by: user4872285 on May 6, 2013 6:49 PM
    Edited by: user4872285 on May 6, 2013 7:01 PM
    Edited by: user4872285 on May 6, 2013 8:02 PM
    Edited by: user4872285 on May 6, 2013 8:03 PM

    PL/SQL code usually leaks reference cursors and DBMS_SQL cursors - as the ref cursor/DBMS_SQL interface used has a global (session static) scope.
    PL/SQL has an intelligent garbage collector that will close local implicit and explicit cursors, when the cursor variable goes out of scope.
    If you define an explicit cursor globally (package interface), then it can only be opened once. The 2nd attempt results in a ORA-06511: PL/SQL: cursor already open exception. So code cannot leak explicit cursors as code cannot reopen an existing opened explicit cursor.
    I have never seen Oracle leaking cursors internally. So I would be hesitant to call what you are seeing, a bug. If your code is using explicit cursors (even static/global ones), your code cannot leak these cursors, even if your code does not close them. Worse case - the cursor remains open, however new copies cannot be created while it is open.
    So I think your are looking at the wrong thing - explicit cursors. These are not the cursors that are leaking in my view (simply because code cannot reuse and open an already opened explicit cursor). Here is an example:
    SQL> show parameter cursors
    NAME                                 TYPE        VALUE
    open_cursors                         integer     300
    session_cached_cursors               integer     50
    // procedure that seems to "leak" an explicit cursor handle
    // as it does not explicitly closes the handle
    SQL> create or replace procedure CursorUse is
      2          cursor c is select e.* from emp e;
      3          empRow  emp%RowType;
      4  begin
      5          open c;
      6          fetch c into empRow;
      7          --// not closing explicit cursor handle
      8          --// and going out-of-scope
      9  end;
    10  /
    Procedure created.
    // current session stats
    SQL> select b.name, a.value from v$mystat a, v$statname b where a.statistic# = b.statistic# and b.name like '%open%cursor%';
    NAME                                  VALUE
    opened cursors cumulative                91
    opened cursors current                    2
    // execute proc that "leaks" a cursor, 10000 times
    SQL> begin
      2          for i in 1..10000 loop
      3                  CursorUse;
      4          end loop;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    // no errors due to cursor leakage
    // session stats: no cursor leakage occurred as
    // PL/SQL's garbage collector cleaned (and closed)
    // cursor handles when these became out-of-scope
    SQL> select b.name, a.value from v$mystat a, v$statname b where a.statistic# = b.statistic# and b.name like '%open%cursor%';
    NAME                                  VALUE
    opened cursors cumulative            10,095
    opened cursors current                    2
    SQL> So the cursor leakage you are seeing is caused by something else... so what else is part of the code, or the session, that you have not yet mentioned?

  • Open cursor for string and select from partition (cannot bind)

    Hi,
    i don't manage to use a bind variable for a select ... from ... PARTITION(...).
    It doesn't work to use something like
    open cur for 'select ... from ... PARTITION(:1) where ...' using 'NDAY_20120301';So i have to create the cursor string with string functions each time i change the partition.
    But that means, that the string changes each time.
    Doesn't that prevent from re-use in library_cache?
    best regards,
    Frank

    >
    So i have to create the cursor string with string functions each time i change the partition.
    But that means, that the string changes each time.
    >
    Yes it does.
    Doesn't that prevent from re-use in library_cache?
    >
    Yes it does.
    So why do you care? Unless you have large numbers of partitions what difference does it make? Bind variables are useful to keep Oracle from doing hard parses of queries that are basically the same but use different filter values. Such as an INSERT statement that uses different values FOR EACH ROW rather
    You are just constructing the main (non-filter) part of the query one time and need a single value for the entire query regardless of how many rows - that isn't really a use case for bind variables and isn't going to provide any real benefit.
    So the real question is why do you even care about something that wouldn't provide any benefit to you even if you could do it?
    Looks like you just want to 'roll your own' parallel processing rather that use, and pay for, Oracle's parallel functionality.
    If each partition uses its own tablespace you could filter on the FILE Id of the ROWIDs since the file number will be different for each tablespace and datafile.
    1. Determine the list of file numbers for each partitions tablespace.
    2. Use a WHERE DBMS_ROWID.ROWID_RELATIVE_FNO (ROWID) = :n filter (or use IN (:n1, :n2))to filter rows based on file number(s) for the partition you want
    See DBMS_ROWID.ROWID_RELATIVE_FNO in the PL/SQL Packages and Types doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_rowid.htm#i1004259

Maybe you are looking for

  • Restoring files from Time Machine after installing Maverick

    I have an older MacBook Pro and while installing Maverick my aged hard drive gave out. I got a new hard drive installed by an authorized Mac dealer and now I'm trying to restore files from Time Machine. I haven't done anything at all yet with Maveric

  • Comparison of Data Loading techniques - Sql Loader & External Tables

    Below are 2 techniques using which the data can be loaded from Flat files to oracle tables. 1)     SQL Loader: a.     Place the flat file( .txt or .csv) on the desired Location. b.     Create a control file Load Data Infile "Mytextfile.txt" (-- file

  • Sync iCloud with On My Mac - or merge the two

    I have noticed that since upgrading to Lion, ios 5, and switching over from Mobile Me to iCloud, I now have duplicates in my Address Book contacts.  I am assuming it is due to the switch to iCloud.  Previously, I had my Address Book set to sync with

  • Lumia 800 Keyboard Problem - Is this Normal?

    When using some apps (Facebook, for example) the virtual keyboard becomes partially unresponsive - pressing any key in the bottom two rows is almost impossible. Also, in the messaging app, the 'send' button is inactive when the keyboard is visible. I

  • FWSM OS upgrade in Active/Active mode

                       Hi All,    Can you please share me the procedure to upgrade FWSM in Active/Active mode with minimum downtime. Regards, Ajith