Closing an implicit cursor

Hi,
Can anyone let me know how to close an implicit cursor opened for every individual sql statement? Please note that I am talking about the implicit cursor, not the explicit cursor. I am reaching the maximum open cursor limit and I don't want to increase the open_cursor parameter further as i have already set it a very big value (10000). Rather I would like to know how to close the implicit cursors opened by oracle itself.
Please help.
Thanks in advance.

Thanks for your advice. In fact we have already
started re-constructing our coding using explicit
cursor. But the thing is even if the implicit cursors
are kept open till the session ending, it should be
closed when the maximum open_cursor limit is reached
by oracle itself.
The work arroud is well accepted, but I am very eager
to know whether somehow implicit cursor can be closed
or not.You have cursor leaks in your application. Are you closing the cursors? In JDBC (I know you said VB.Net but I don't know much about VB) you call the close method on the Statement objects. May be you are closing most of the cursors but a few are not being closed. In that case, the number of open cursors will slowly creep up to a high number. How often does this error come up? How long before you start seeing it?
Also, take a look at the v$open_cursor view (using your session SID) when you get the error and see if there are certain statements that are repeated a ton of times. This could help you find those statements that are not closed by the application.
Also note, there is a dbms_sql.close_cursor method. Check it out:
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg09dyn.htm#26799
-Raj

Similar Messages

  • Question on Synonyms and Implicit Cursor

    Hi,
    I've two doubts.
    Question1:
    Why Oracle is allowing me to create a synonym even base object does not exist in database.
    For example in below example user ABC and object def doesnt exist in my database. Why I didnt get any error while creating a synonym.
    Connected to Oracle Database 11g Express Edition Release 11.2.0.2.0
    Connected as hr
    SQL> CREATE SYNONYM test_syn FOR ABC.def;
    Synonym created
    SQL> Question2:
    In PL/SQL after closing the cursor if we use any cursor attribute it will throw exception like invalid cursor. Why it is not happening in case of implicit cursor.
    Or
    Does Oracle close implicit cursor(SQL) ?
    declare
    begin
      UPDATE emp
      SET ename = 'SURI';
    COMMIT;
    dbms_output.put_line(SQL%rowcount);
    end;Many thanks for all your help.
    Cheers,
    Suri

    Suri wrote:
    Hi,
    I've two doubts.
    Question1:
    Why Oracle is allowing me to create a synonym even base object does not exist in database.
    For example in below example user ABC and object def doesnt exist in my database. Why I didnt get any error while creating a synonym.If you look in the all_dependencies view you will see that it's created as "NON-EXISTENT", so oracle knows it's non existent, it just doesn't treat it as an error.
    As it says in the documentation:
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_7001.htm#SQLRF01401
    A dependency is created and if the target object is changed or dropped etc. the synonym becomes invalid... but that doesn't mean it cannot exist.
    Question2:
    In PL/SQL after closing the cursor if we use any cursor attribute it will throw exception like invalid cursor. Why it is not happening in case of implicit cursor.Would you care to demonstrate what you mean with some code.

  • Difference between implicit cursor and explicit cursor.

    hi all,
    i have used explicit cursor, i know the way of using implicit cursor, but i don't what the difference between both.
    Is they both are different. if yes y? which cursor is most reliable to use.
    please tell me..
    Thanks..

    OK,
    1- An IMPLICIT cursor is automatically declared by Oracle every time an SQL statement is executed The user will not be aware of this happening and will not be able to control or process
    the information in an implicit cursor.
    Example:
    SET SERVEROUTPUT ON
    BEGIN
    UPDATE Customers
    SET Cust_name = 'B'
    WHERE Cust_name LIKE 'B%';
    DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT);
    END;
    2- An EXPLICIT cursor is defined by the program for any query that returns more than one row of data.
    That means the programmer has declared the cursor within the PL/SQL code block. This declaration allows for the application to sequentially process each row of data as it is returned by the cursor.
    Example :
    DECLARE
    CURSOR C_MyCursor IS
    SELECT *
    FROM bookings
    WHERE Cust_no = 701;
    see this post
    http://comsci.liu.edu/~vasilaky/db2/cursors.htm :-)

  • Problem in using String in Implicit Cursor

    Hi,
    I am facing problem in using String in Implicit Cursor:
    I have initialise
    DECLARE
    v_grant varchar2(4000);
    begin
    v_grant:='SELECT TABLE_NAME FROM DUMP_USER_TABLES WHERE TABLE_NAME LIKE ';
    FOR obj IN (SELECT v_grant||'''BS%''' FROM dual) LOOP
    V_REVOKE:='REVOKE ALL ON ' || 'obj.TABLE_NAME' || ' FROM ' || '''TEST''';
    DBMS_OUTPUT.PUT_LINE('THE REVOKE STATEMENT IS'||V_REVOKE);
    num := num + 1;
    END LOOP;
    END;
    I am not getting the value from obj.TABLE_NAME its coming as 'obj.TABLE_NAME'
    Kindly anyhelp will be needful for me

    Besides from what Sybrand already pointed out clearly:
    Your example doesn't run at all:
    MHO%xe> DECLARE
      2  v_grant varchar2(4000);
      3  begin
      4  v_grant:='SELECT TABLE_NAME FROM DUMP_USER_TABLES WHERE TABLE_NAME LIKE ';
      5  FOR obj IN (SELECT v_grant||'''BS%''' FROM dual) LOOP
      6  V_REVOKE:='REVOKE ALL ON ' || 'obj.TABLE_NAME' || ' FROM ' || '''TEST''';
      7  DBMS_OUTPUT.PUT_LINE('THE REVOKE STATEMENT IS'||V_REVOKE);
      8  num := num + 1;
      9  END LOOP;
    10  END;
    11  /
    V_REVOKE:='REVOKE ALL ON ' || 'obj.TABLE_NAME' || ' FROM ' || '''TEST''';
    FOUT in regel 6:
    .ORA-06550: line 6, column 1:
    PLS-00201: identifier 'V_REVOKE' must be declared
    ORA-06550: line 6, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 7, column 49:
    PLS-00201: identifier 'V_REVOKE' must be declared
    ORA-06550: line 7, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 8, column 1:
    PLS-00201: identifier 'NUM' must be declared
    ORA-06550: line 8, column 1:
    PL/SQL: Statement ignoredI guess you need to read up on quoting strings properly and probably also dynamic SQL.
    But:
    WHAT are you trying to do anyway?
    I cannot parse your code at all...so what is your requirement in human language?

  • Exception in implicit cursor

    In the following block, I am unable to figure out how to catch
    no_data_found in the SQL within the for loop.
    no_data_found in the exception part doesn't catch it. Any ideas
    would be much appreciated.
    begin
    for xx in(select ename from emp where hire_date > trunc(sysdate,'MM'))
    loop
    dbms_output.put_line('ename '||xx.ename);
    end loop;
    exception
    when no_data_found then dbms_output.put_line('no record found');
    end;
    thanks.
    arniko

    The NO_DATA_FOUND exception is only raised when using an implicit cursor in PL/SQL. E.g.
    select f.id into my_variable from foo f where f.day = trunc(sysdate);
    ..When opening a cursor, where you deal with the actual cursor handle (variable xx in your sample code), you use an explicit cursor reference. And in this case, the exception is not raised and you're expected to use the cursor variable called %NOTFOUND instead.

  • Avoid procedure or function calls between a SQL operation and an implicit cursor test

    when i analyse this code with code expert

    atpidgeon wrote:
    when i analyse this code with code expert
                            UPDATE P_PM_CONTROL_COUNT
                            SET AVAIL_SEG = AVAIL_SEG -1,
                                ALLOCATION = ALLOCATION -1
                            WHERE PM_UNIT_TYPE_ID = vrectab(1)
                            AND USAGE_DATE = vrectab(2)
                            AND SEGMENT_CODE = vrectab(5)
                            AND ALLOCATION - UNITS_RESERVED > 0;
                            IF sql%rowcount = 0 then --Added block and exception to prevent invetory going negative when placing multi units in same unit type out of service.
                                vErrMsg := 'Could not process your out of service request because your selection for unit '|| vrectab(3) || ' at ' || pvPropertyId || ' for ' || vrectab(2) || ' would cause segment ' || vrectab(5) || ' to be over allocated.';
                                RAISE SegOverAllocated;
                            END IF;
    i get "Avoid procedure or function calls between a SQL operation and an implicit cursor test.",as far has i know
    iff you're doing a sql%rowcount    after an update.. trying to see how many rows were updated...  you dont want procedure or function calls between the update and the sql% line
    correct me if im wrong and how would i fix it?or maybe i shouldnt
    You correct it by NOT executing function calls as part of the UPDATE statement.
    1. Issue the function calls BEFORE the update statement
    2. save the function results into variables
    3. use those variables in the UPDATE statement.
    v_rectab1 := vrectab(1);
    v_rectab2 := vrectab(21);
    v_rectab5 := vrectab(5);
    UPDATE P_PM_CONTROL_COUNT 
                            SET AVAIL_SEG = AVAIL_SEG -1,
                                ALLOCATION = ALLOCATION -1
                            WHERE PM_UNIT_TYPE_ID = v_rectab1
                            AND USAGE_DATE = v_rectab2
                            AND SEGMENT_CODE = v_rectab5
                            AND ALLOCATION - UNITS_RESERVED > 0;

  • Type Mismatch using Implicit Cursor

    The actual error I get is
    PLS-00386: type mismatch found at 'EMP_REC' between FETCH cursor and INTO variables
    I have copied the code in below (taken some logic out to make example easier). I think the problem is with the EMP_REC CHILDKNOWDES declaration - I dont think I need to add %ROWTYPE? Is the type mismatch a case of trying to parse an int into a string (which i have checked for), or a case of the object being stored with attributes in dif order (alphabetical?), or is something more sinister going on?
    CREATE OR REPLACE TYPE &HKDB_Schema_Name..CHILDKNOWDES AS OBJECT
    KnowdeID INT,
    Description varchar2(512),
    Connector CHAR(1),
    WhyCount INT
    CREATE OR REPLACE TYPE &HKDB_Schema_Name..TEMP_CHILDKNOWDES_TABLE AS TABLE OF &HKDB_Schema_Name..CHILDKNOWDES;
    CREATE OR REPLACE PROCEDURE &HKDB_Schema_Name..QueryChildKnowdes
    aKnowdeID int,
    aCur out sys_refcursor
    AS
    l_ChildKnowdeTable TEMP_CHILDKNOWDES_TABLE := TEMP_CHILDKNOWDES_TABLE();
    EMP_REC CHILDKNOWDES;
    BEGIN
         DECLARE CURSOR c1 is SELECT k.KnowdeID, k.Description, KnowdeAssociation.Connector
            FROM Knowde k
            INNER JOIN KnowdeAssociation ka on ka.KnowdeID = k.KnowdeID
    BEGIN
         OPEN c1;
         FETCH c1 INTO EMP_REC;    --error
         WHILE c1%FOUND
         LOOP
         BEGIN
              QueryWhyCount(EMP_REC.KnowdeID, aWhyCountResult);
                 l_ChildKnowdeTable.extend;
              l_ChildKnowdeTable(l_ChildKnowdeTable.last) := CHILDKNOWDES
              (EMP_REC.KnowdeID,
              EMP_REC.Description,
              EMP_REC.Connector,
              aWhyCountResult);
              FETCH c1 INTO EMP_REC;    --error
         END;
         END LOOP;
         END;
    END QueryChildKnowdes;Thanks in advance,
    Toby

    Knowde
    Name                                      Null?    Type
    KNOWDEID                                  NOT NULL NUMBER(10)
    VERBID                                    NOT NULL NUMBER(10)
    NOUNID                                    NOT NULL NUMBER(10)
    KGID                                      NOT NULL NUMBER(10)
    DATECREATED                               NOT NULL DATE
    DESCRIPTION                                        VARCHAR2(51
    UDRID                                              NUMBER(10)
    UVRID                                              NUMBER(10)
    RESOURCEID                                         NUMBER(10)
    VERSIONID                                          NUMBER(10)
    CHECKEDOUT                                         NUMBER(1)
    CLIENTKNOWDEID                                     NUMBER(10)
    GENERICKNOWDEID                                    NUMBER(10)
    SOURCEKNOWDEID                                     NUMBER(10)
    UNEDITABLE                                         NUMBER(1)
    DATEUPDATED                               NOT NULL DATE
    PREVIOUSKNOWDEID                                   NUMBER(10)KnowdeAssociation
    Name                                      Null?    Type
    KNOWDEASSOCIATIONID                       NOT NULL NUMBER(10)
    HOWID                                     NOT NULL NUMBER(10)
    WHYID                                     NOT NULL NUMBER(10)
    CONNECTOR                                          CHAR(1)
    HOWCHAINPOSITION                                   NUMBER(10)
    WHYCHAINPOSITION                                   NUMBER(10)

  • Closing a ref cursor

    Hello,
    if i have:
    function getPersoaneContact(v_id_client in clienti.id%type)
        return ref_cursor is
        tmp ref_cursor;
      begin
        open tmp for
          select ........ from ..... where ....
        return tmp;
      end;Where should i close that ref cursor? Or.. should i close it?
    Thanks!

    Tom had already discussed about this.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1606716582692
    Regards,
    Prazy

  • Is it good to use For implicit cursors to fetch only one row ?

    I mean is it good to use something below.
    function isThereAny (inCompany) return boolean is
    begin
            for x in ( select 'x' from company_relation
                        where  company=inCompany
                          and nvl(europe_yn,'N')='Y' ) loop
              return true;
            end loop;
            return false;
    end isThereAny;  Thanks

    This construction seems to be approximately 10% faster than a regular select into on 9.2.0.7.0. But I think the code is less clear for maintenance than a regular select into. When I look at the code, my first thought is it is going to loop through some records, and on second thought it is not. I don't like that, but it is a matter of personal taste.
    When you don't have problems with that or when you really need that 10% on the function, it is perfectly ok.
    SQL> create function isThereAny_for (p_deptno in dept.deptno%type) return boolean
      2  is
      3  begin
      4    for x in
      5    ( select 'x'
      6        from emp
      7       where deptno = p_deptno
      8         and nvl(comm,0) > 0
      9    )
    10    loop
    11      return true;
    12    end loop
    13    ;
    14    return false
    15    ;
    16  end isThereAny_for;
    17  /
    Functie is aangemaakt.
    SQL> create function isThereAny_into (p_deptno in dept.deptno%type) return boolean
      2  is
      3    l_x varchar2(1);
      4  begin
      5    select 'x'
      6      into l_x
      7      from emp
      8     where deptno = p_deptno
      9       and nvl(comm,0) > 0
    10    ;
    11    return true;
    12  exception
    13  when no_data_found then
    14    return false;
    15  when too_many_rows then
    16    return true;
    17  end isThereAny_into;
    18  /
    Functie is aangemaakt.
    SQL> begin
      2    -- Warming up
      3    for i in 1..4
      4    loop
      5      if isThereAny_for(i*10)
      6      then
      7        null;
      8      end if;
      9    end loop;
    10    for i in 1..4
    11    loop
    12      if isThereAny_into(i*10)
    13      then
    14        null;
    15      end if;
    16    end loop;
    17    -- Start test
    18    runstats_pkg.rs_start;
    19    for i in 1..10000
    20    loop
    21      if isThereAny_for((mod(i,4)+1)*10)
    22      then
    23        null;
    24      end if;
    25    end loop;
    26    runstats_pkg.rs_middle;
    27    for i in 1..10000
    28    loop
    29      if isThereAny_into((mod(i,4)+1)*10)
    30      then
    31        null;
    32      end if;
    33    end loop;
    34    runstats_pkg.rs_stop(100);
    35  end;
    36  /
    Run1 draaide in 200 hsecs
    Run2 draaide in 216 hsecs
    Run1 draaide in 92,59% van de tijd
    Naam                                                    Run1      Run2  Verschil
    LATCH.simulator hash latch                               154       439       285
    LATCH.redo allocation                                  2,530     2,817       287
    LATCH.row cache enqueue latch                            140       494       354
    LATCH.sequence cache                                   3,614     4,006       392
    LATCH.row cache objects                                  384       791       407
    LATCH.library cache pin                               34,415    36,019     1,604
    LATCH.shared pool                                     17,207    18,929     1,722
    LATCH.library cache                                   35,591    37,587     1,996
    STAT.table scan rows gotten                          110,000   112,500     2,500
    STAT.db block gets                                        12     5,015     5,003
    STAT.session logical reads                            30,017    35,023     5,006
    STAT.recursive calls                                  12,501    20,001     7,500
    LATCH.cache buffers chains                           113,839   134,592    20,753
    Run1 latches totaal versus run2 -- verschil en percentage
          Run1      Run2  Verschil     Pct
       208,826   236,934    28,108  88.14%
    PL/SQL-procedure is geslaagd.Regards,
    Rob.

  • Implicit and explicit cursors

    i want to know when to it is recommended to use the implicit cursors (for rec in….) and when it is recommended to use explicit cursors(open cursors….)

    As Brett said, both methods require an explicit cursor definition. What is implicit in the FOR cursor loop is the opening and closing of the cursor. If you use a cursor FETCH loop, you need to code that explicitly yourself.
    My recommendation is to use the cursor FETCH loop and code those two additional OPEN CURSOR and CLOSE CURSOR statements. Reason: a cursor fetch loop allows for proper bulk processing code to be used. It does not rely on the implicit bulk fetching (of 10 rows per time) of a FOR cursor loop - which btw is only available in 10G.
    A FOR cursor loop does not scale. You cannot make the bulk fetching larger. Or smaller. You cannot do bulk updates or inserts in the loop.
    So I do not care what the experts think and say, for me the answer is clear cut. You want to write scalable and performant code? You will use a cursor fetch loop. Not a for cursor loop.

  • Cursors remained open after closing connection

    I am using OC4J 10g (Application Server) and Oracle10g DB. OC4J is maintaining the connection pool(com.evermind.sql.DriverManagerDataSource). I get the connection from pool and call DB procedure, then close resultset, statement and connection. It closes the opened cursors against resultset. But left some implicit cursors opened and never closed so cursor count is going to increase.
    If i dont use pool no cursor remained open and count is zero. It means the cursors of pooled connections are not closed.
    wait-timeout="60"
    min-connections="5"
    max-connections="100"
    inactivity-timeout="15"
    <property name="stmt-cache-size" value="2000"/>
    Tahir

    Hi Justin,
    Thnx for your reply and you're understanding is correct but the problem I face is when multiple concurrent users access the JSP page from which I'm actually calling the servlet to retrieve the image, the number of cursors being left open increases. As the load on the page increases (i.e. no of usesrs increase) oracle seems to have problems in garbage collecting the open cursors ... which eventually leads it to throw maximum cursors exceeded exceptions.
    Any suggestions ?
    -Athar

  • Implicit PL/SQL cursors remain open, causing ORA-01000 (Client 9.2.0.1)

    Hello,
    since migrating our system from Oracle Client 9.0.X to 9.2.0.1 (Windows XP), i am encountering troubles when calling a stored procedure from a Cobol-Program:
    after a while i run into a 'Maximum open cursors exceeded'-message (ORA-01000)
    The stored procedure returns a cursor (ref_cursor)
    When Executing the stored procedure, there are actually 2 cursors involved, in fact the stored PL/SQL procedure implicitely opens a child-cursor when doing a select within the PL/SQL.
    After fetching the result and closing the cursor in my cobol-program, it correctly closes the cursor associated with the stored-procedure, but it does not close the cursor that was implicitely opened by oracle.
    After a while i am running into a Maximum open cursors message, because those cursors have not properly been closed.
    Here's a simple PL/SQL package that illustrates the problem:
    create or replace package scott.SCOTTS_PACKAGE is
    type ref_cursor IS REF CURSOR;
    function GET_EMP(EMP_IN CHAR) return ref_cursor;
    end SCOTTS_PACKAGE;
    create or replace package body scott.SCOTTS_PACKAGE is
    -- Function and procedure implementations
    function GET_EMP(EMP_IN CHAR) return ref_cursor is
    MyCurs ref_cursor;
    begin
    OPEN MyCurs FOR
    SELECT EMPNO ,
    ENAME ,
    JOB
    FROM SCOTT.EMP
    WHERE ENAME = EMP_IN;
    return(MyCurs);
    end;
    end SCOTTS_PACKAGE;
    Here are some exerpts from my cobol program:
    (The program iterates 100x through the section that executes the PL/SQL. After each iteration an additional open cursor remains in the database)
    003800 EXEC SQL BEGIN DECLARE SECTION END-EXEC.
    003900*
    004000 01 SQL-USERNAME PIC X(16) VARYING.
    004100 01 SQL-PASSWD PIC X(16) VARYING.
    004200 01 SQL-DBNAME PIC X(64) VARYING.
    004300 01 ORACLE.
    004700 02 ORA-CUR-EMP SQL-CURSOR.
    01 EMPREC.
    02 EMPREC-EMPNO PIC X(4).
    02 EMPREC-ENAME PIC X(10).
    02 EMPREC-JOB PIC X(9).
    005400 EXEC SQL END DECLARE SECTION END-EXEC.
    018400 PROCEDURE DIVISION.
    CONTINUE.
    018700 EXEC SQL
    018800 WHENEVER SQLERROR DO PERFORM SQL-ERROR
    018900 END-EXEC.
    019000*
    CONTINUE.
    019100 EXEC SQL
    019200 WHENEVER NOT FOUND DO PERFORM SQL-NOT-FOUND
    019300 END-EXEC.
    022400 EXEC SQL
    022500 ALLOCATE :ORA-CUR-EMP
    022600 END-EXEC
    PERFORM VARYING I FROM 1 BY 1 UNTIL I > 100
    ACCEPT DUMMY FROM TER
    IF DUMMY = "E"
    MOVE 100 TO I
    END-IF
    PERFORM GET-EMP
    ADD 1 TO I
    END-PERFORM
    119300 GET-EMP SECTION.
    119400************************
    119500 GAM0.
    MOVE SPACES TO EMPREC-EMPNO EMPREC-JOB
    MOVE "SMITH" TO EMPREC-ENAME
    120200 EXEC SQL AT SSSI EXECUTE
    120300 BEGIN
    120400 :ORA-CUR-EMP:=
    120500 SCOTT.SCOTTS_PACKAGE.GET_EMP(:EMPREC-ENAME );
    120900
    END;
    121000 END-EXEC
    121200 IF DB-ERR-CODE NOT = HIGH-VALUE
    121300 DISPLAY "CCSIFSO:GET-AUTRE-MATR:APPEL PERS... OK"
    121400 EXEC SQL
    121500 FETCH :ORA-CUR-EMP
    121600 INTO
    121700 :EMPREC-EMPNO,
    121800 :EMPREC-ENAME,
    121900 :EMPREC-JOB
    122400 END-EXEC
    122500 END-IF
    122600*
    122700 IF DB-ERR-CODE NOT = HIGH-VALUE
    122800 DISPLAY "CCSIFSO:GET-AUTRE-MATR:APPEL FETCH.. OK"
    123000 ELSE
    123100 MOVE LOW-VALUE TO DB-ERR-CODE
    123200 END-IF
    123300 EXEC SQL
    123400 CLOSE :ORA-CUR-EMP
    123500 END-EXEC
    123600 GA-EX.
    123700 EXIT.
    124000 SQL-NOT-FOUND SECTION.
    124100*----------------------
    124200 NF0.
    124300 DISPLAY "CCSIFSO:SQL-NOT-FOUND SECTION."
    124400 MOVE HIGH-VALUE TO DB-ERR-CODE.
    124500 NF-EX.
    124600 EXIT.
    124700*
    124800 SQL-ERROR SECTION.
    124900*-----------------
    125000 ER0.
    125200 EXEC SQL
    125300 WHENEVER SQLERROR CONTINUE
    125400 END-EXEC
    125700 MOVE HIGH-VALUE TO DB-ERR-CODE
    125800*
    126100 DISPLAY "ORACLE ERROR DETECTED: " SQLCODE UPON TER
    126200 DISPLAY SQLERRMC UPON TER
    126300*
    126400 EXEC SQL AT SSSI
    126500 ROLLBACK WORK
    126600 RELEASE
    126700 END-EXEC
    126800 DISPLAY "----------------------------" UPON TER
    126900 DISPLAY " ! ROLLBACK ET DISCONNECT ! " UPON TER
    127000 DISPLAY "----------------------------" UPON TER
    127200 CALL "PPTERMJ".
    127400 ER-EX.
    127500 EXIT.
    Finally here's an exerpt from V$OPEN_CURSOR, after a few iterations:
    1 begin :b1 := SCOTT . SCOTTS_PACKAGE . GET_EMP (:b2 ) ; END ;
    2 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    3 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    4 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    5 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    6 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    7 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    8 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    9 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    10 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    11 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    As you see, there is only 1 cursor starting with 'begin ... '
    but there are 10 implicit cursors 'SELECT EMPNO, ... ' that have not been properly closed, nor reused by ORACLE.
    In our old configuration (ORACLE CLient 9.0.X), you would only see:
    1 begin :b1 := SCOTT . SCOTTS_PACKAGE . GET_EMP (:b2 ) ; END ;
    2 SELECT EMPNO , ENAME , JOB FROM EMP WHERE ENAME = :B1
    meaning all the other cursors have properly been closed.
    As a conclusion: the program correctly closes the implicit cursors when using a 9.0 Client, wheras the implicit cursors remain open on Client 9.2.0.1 (Windows XP)
    The underlying database can be either 8.i or 9, the problem remains the same.
    Finally here's a small Delphi code, using ODAC-components, that somewhat illustrates the same problem:
    procedure TForm1.ExecProcClick(Sender: TObject);
    var I: INTEGER ;
    begin
    FOR I := 1 TO 5 DO
    BEGIN
    SP1.StoredProcName:='SCOTT.SCOTTS_PACKAGE.GET_EMP';
    SP1.Prepare;
    SP1.ParamByName('EMP_IN').AsString := 'SMITH';
    SP1.ExecProc;
    SP1.Next;
    SP1.Close;
    SP1.UnPrepare;
    END;
    end;
    After each call to 'PREPARE', an additional implicit cursor remains open on the database. (using Oracle Client 9.2.0.1)
    On our old system (Oracle Client 9.0 or 8.X), the same program would not generate accumulating open cursors on the database
    Any suggestions would be welcome,
    Claude

    Cobol.. been many years since I last even saw some Cobol source code. Invokes all kinds of memories. :-)
    Since you found the patch, the advice is superfluous, but works. Close the cursor at the PL/SQL side, e.g.
    create or replace procedure CloseRefCursor( cRefCursor TYPELIB.TRefCursor ) is
    begin
      close cRefCursor;
    exception when OTHERS then
      -- if the cursor is already gone, not a problem
      NULL;
    end;In Delphi for example, one can subclass the class used for ref cursor calls and add a call to the above PL/SQL proc in the destructor. Or add create a standard Cobol close ref cursor section that does similar.

  • What is implicit and explicit cursor ?

    I need to know what is implicit cursor and what is Explict one with a sample source.
    Also what is the difference between these two?
    Thank you

    Check this:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref1274

  • Difference between Implicit and Explicit Cursors

    Hi All,
    Can you just tell me what is the difference between implicit and explicit cursor?
    Thanks,
    Padma

    Hi ,
    Implicit Cursor means ,the cursors which are defined impplicitly.Here we use curosr variables as "SQL%found,sql%not found,sql%is open.."
    but explicit cursors defined by us like if u create a cursor C1 then
    c1%found,c1% not found ,c1%open
    Thank you.

  • Ref Cursor over Implicit and explicit cursors

    Hi,
    In my company when writing PL/SQL procedure, everyone uses "Ref Cursor",
    But the article below, says Implicit is best , then Explicit and finally Ref Cursor..
    [http://www.oracle-base.com/forums/viewtopic.php?f=2&t=10720]
    I am bit confused by this, can any one help me to understand this?
    Thanks

    SeshuGiri wrote:
    In my company when writing PL/SQL procedure, everyone uses "Ref Cursor",
    But the article below, says Implicit is best , then Explicit and finally Ref Cursor..
    [http://www.oracle-base.com/forums/viewtopic.php?f=2&t=10720]
    I am bit confused by this, can any one help me to understand this?There is performance and there is performance...
    To explain. There is only a single type of cursor in Oracle - that is the cursor that is parsed and compiled by the SQL engine and stored in the database's shared pool. The "+client+" is then given a handle (called a SQL Statement Handle in many APIs) that it can use to reference that cursor in the SQL engine.
    The performance of this cursor is not determined by the client. It is determined by the execution plan and how much executing that cursor cost ito server resources.
    The client can be Java, Visual Basic, .Net - or a PL/SQL program. This client language (a client of SQL), has its own structures in dealing with that cursor handle received from the SQL engine.
    It can hide it from the developer all together - so that he/she does not even see that there is a statement handle. This is what implicit cursors are in PL/SQL.
    It can allow the developer to manually define the cursor structure - this is what explicit cursors, ref cursors, and DBMS_SQL cursors are in PL/SQL.
    Each of these client cursor structures provides the programmer with a different set of features to deal with SQL cursor. Explicit cursor constructs in PL/SQL do not allow for the use of dynamic SQL. Ref cursors and DBMS_SQL cursors do. Ref cursors do not allow the programmer to determine, at run-time, the structure of the SQL projection of the cursor. DBMS_SQL cursors do.
    Only ref cursors can be created in PL/SQL and then be handed over to another client (e.g. Java/VB) for processing. Etc.
    So each of the client structures/interfaces provides you with a different feature set for SQL cursors.
    Choosing implicit cursors for example does not make the SQL cursor go faster. The SQL engine does not know and does not care, what client construct you are using to deal with the SQL cursor handle it gave you. It does not matter. It does not impact its SQL cursor performance.
    But on the client side, it can matter - as your code in dealing with that SQL cursor determines how fast your interaction with that SQL cursor is. How many context switches you make. How effectively you use and re-use the SQL (e.g. hard parsing vs soft parsing vs re-using the same cursor handle). Etc.
    Is there any single client cursor construct that is better? No.
    That is an ignorant view. The client language provides a toolbox, where each tool has a specific application. The knowledgeable developer will use the right tool for the job. The idiot developer will select one tool and use it as The Hammer to "solve" all the problems.

Maybe you are looking for

  • Error in MIGO

    Hi, When I try to issue a Goods Receipt in plant Z1Z1 (Movement Type 501 - Receipt w/o PO), I get the error below. <b>"Combination of plant Z1Z1 and material type SE Product/SubAss/Comp does not exist."</b> (Long Text follows below.) <b>Diagnosis</b>

  • Updated to Safari 5 now getting a ct_plugin error and wont open

    I've seen that many people have had this issue before and I've followed all the directions in all the previous posts in order to solve my issue but none of those methods are working for me. This is the problem I reported: Process: Safari [1575] Path:

  • Restoer exchange server 2010 DAG

    hi could you please let me know the prerequisite for restoration of exchange 2010 DAG which has broken one months ago. <p>Don't forget to mark helpful or answer</p> <p>connect me :-</p> <p>http://in.linkedin.com/in/satya11</p> <p>http://facebook.com/

  • IPhoto 4.0.3 mixed up photo order & mismatched titles

    I have no idea what I did, but after getting the message that my startup disk was nearly full after downloading about 1000 new photos I frantically statred deleting music files and other old docs with lots of graphics. My Toshiba MK3025 GAS hard driv

  • TS3297 I tried to download a Bruno Mars song and error message said temporarily unavailable try again later, but still no luck 24 hours later. How to fix?

    I tried to download a Bruno Mars song and it took the money from my account. Error message came up saying song temporarily unavailable, try again later. was able to download other songs tho. 24 hours later and still getting same message, How to fix?