Reg: Multiple Cursor Fetching

Hi All
I have Two Cursors Let us say C1 and C2 .
For i in C1 ------------------having 2 records
Loop
For j in C2 --------------having 3 records;
Loop
end loop;
end loop;
In the Secnd record of C1 , second cursor C2 will loop for 3 times again, but i don't want to use the first record on cursor c2 should not use the first record in the second record of c1.
can any one help out , its very urgent
Regards
venkatesh

user8833410 wrote:
Hi All
I have Two Cursors Let us say C1 and C2 .
For i in C1 ------------------having 2 records
Loop
For j in C2 --------------having 3 records;
Loop
end loop;
end loop;
In the Secnd record of C1 , second cursor C2 will loop for 3 times again, but i don't want to use the first record on cursor c2 should not use the first record in the second record of c1.
can any one help out , its very urgent
Regards
venkateshOddly, you've now asked 8 questions on these forums, and all 8 are apparently unanswered (or you're just too lazy to respond to them or mark them aswered). On top of that, all the questions you've asked have been apparently "Urgent" (though obviously not urgent enough for you to respond to the people who've bothered to answer you)
I would suggest if you want more helpful responses from the volunteers on the forum, you learn how to ask questions...
{message:id=9360002}
and stop saying that your issues are "urgent". You will find you get more help that way.

Similar Messages

  • Effect of Multiple cursors in Function Module Extractors

    Hi,
    I am trying to use multiple cursors in an FM extractor, like this:
    OPEN CURSOR WITH HOLD c1 FOR <select query 1>.
    OPEN CURSOR WITH HOLD c2 FOR <select query 2>.
    FETCH NEXT CURSOR c1
                   INTO CORRESPONDING FIELDS
                   OF TABLE i_equi.
    FETCH NEXT CURSOR c2
                   APPENDING CORRESPONDING FIELDS
                   OF TABLE i_equi.
    " Further processing of equipments
    " obtained in i_equi
    I am also checking SY-SUBRC, after each Fetch statement. If both cursors happen to be empty, the extractor exits by raising no_more_data, like other extractors.
    It is possible to do so, since I just tried it. The question is, are there any disadvantages of this kind of approach in terms of memory or speed?
    Edited by: Suhas Karnik on Sep 29, 2008 12:06 PM

    hI kiran,
    The simple way is to create a data element & domain with value range where u provide set of fixed values or provide a check table to it.
    Use that data element in a table <ztable>.
    Code:
    Parameters:
          p_burks like <ztable>-dataelement.
    Call Function <function_name>
    exporting
    p_burks = p_burks,

  • "multiple cursor in a procedure" is possible?

    Hi.. everyone.
    Is it possible , "multiple cursor in one procedure"?
    For example,
    create or replace procedure xxx
    is
    vAAA varchar2(10);
    vBBB varchar2(10);
    cursor cur_1 is select .............................;
    cursor cur_2 is select .............................;
    begin
    -- the first cursor
    open cur_1;
    loop
    end loop;
    close cur_1;
    -- the second cursor
    open cur_2;
    loop
    end loop;
    close cur_2;
    end;
    If it is not possible, what is the way to use
    multiple cursor(more than 2) in ONE procedure?
    Thanks in advance.
    Have a nice day.
    Ho.

    no problem
    SQL> drop procedure xxx;
    Procedure dropped.
    SQL> CREATE OR REPLACE
      2  procedure xxx
      3  is
      4  vAAA varchar2(10);
      5  vBBB varchar2(10);
      6  cursor cur_1 is select employee_id from employees where rownum < 2;
      7  cursor cur_2 is select department_id from departments where rownum < 2;
      8
      9  begin
    10  -----------------------------------------------
    11  -- the first cursor
    12  -----------------------------------------------
    13  dbms_output.put_line('Cursor 1 Result');
    14  open cur_1;
    15  loop
    16    fetch cur_1 into vAAA;
    17    exit when cur_1%notfound;
    18    dbms_output.put_line(vAAA);
    19  end loop;
    20  close cur_1;
    21  -----------------------------------------------
    22  -- the second cursor
    23  -----------------------------------------------
    24  dbms_output.put_line('Cursor 2 Result');
    25  open cur_2;
    26  loop
    27    fetch cur_2 into vBBB;
    28    exit when cur_2%notfound;
    29    dbms_output.put_line(vBBB);
    30  end loop;
    31  close cur_2;
    32  -----------------------------------------------
    33  end;
    34  /
    Procedure created.
    SQL> execute xxx;
    Cursor 1 Result
    100
    Cursor 2 Result
    10
    PL/SQL procedure successfully completed.

  • How to add (multiple) cursors programmatically in an XY graph?

     how to add (multiple) cursors programmatically in an XY graph?
    I am building an XY graph. then I would like to add cursors at certain locations (positioned on x axis) I determine through a program.
    How can I add cursors programatically?
    Thank you.

    Initialize a cluster array (CrsrList type) with as many cursors as you think you would ever need.   Setup your cursors dynamically, then delete the unused cursors (array elements) and then update your CursorList property.
    Message Edited by vt92 on 03-20-2009 04:04 PM
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
    Attachments:
    cursors.PNG ‏5 KB

  • [Help] statement.executeQuery(query) opens MULTIPLE cursors

    Hey everyone,
    I'm having a real hard time finding anything about this on the net so I've turned here. When we call:
    resultSet = statement.executeQuery(query)
    from a servlet for some reason that one executeQuery opens anywhere from 9-12 cursors in our oracle DB. All the executeQuery documentation I could find just said it should open 1 cursor for that particular ResultSet. query is a fairly simple SQL statement, it searches multiple tables but that doesn't explain why it should open so many cursors.
    On a side note the resultSet and statement are global to the method and are closed in the finally block, no SQLExceptions are thrown further adding to my confusion.
    If anyone has seen something like this where executing 1 query opens multiple cursors please let me know any information you might have.
    Thanks in advance
    -Dave

    Hi Dave
    I had a similar problem using the Oracle 8i, but my query was a more complicated than yours and opened a lot of cursors.
    The answer is to close every ResultSet and the Statement:
    while (xxResult.next()){ ... }
    xxResult.close();
    xxResult.getStatement().close();
    This worked for me,
    Good luck,
    Daniel.

  • Multiple cursor names in xy graph

    Hi,
    I have tried putting the names of multiple cursors that I am using in my xy-graph. But I only able to name only one cursor, not sure where I am going wrong... I want the names of both the cursors appear. I am as such changing the names of the cursors dynamically on the run-time.
    I have attached a .gif, hope I am clear.
    thanks.
    Attachments:
    xy graph.GIF ‏26 KB

    Hi
    This is how I would do it.
    Hope this helps.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...
    Attachments:
    Cursor-Names.PNG ‏12 KB

  • Same EMP NUM in multiple cursors

    My plsql program is designed in such way that there are multiple cursors & each cursor needs input as EMPLOYEE NUMBER.
    This EMPLOYEE NUMBER should be same across all the cursors.
    Code is as below.
    Any kind of help here is appreciated. Thank you in advance.
    -- AGTSP
    SET SERVEROUTPUT ON
    alter session set nls_date_format='YYYY-MM-DD';
    DECLARE
        MY_FILE_DIR varchar2(40) := '/usr/tmp2';
        l_output        utl_file.file_type;
        v_file_handle varchar2(30) default 'Legacy_Job_Data.csv';
        buf varchar2(10230);
        v_ps_id varchar2(10);
        v_job_descr varchar2(40);
      v_belonging_name VARCHAR2(100);
      v_sg VARCHAR2(4);
      v_sg_jc VARCHAR2(6);
      v_EFFECTIVE_START_DATE DATE;
      SG VARCHAR2(10);
      v_count number;
    -- CJL DATA COLLECTION STARTS
    -- CURSOR STARTS
        CURSOR C_MAIN IS        
      select
                        EMP.EMPLOYEE_NUMBER AS EMPLOYEE_NUMBER
      , JOB.BELONGING_NAME
      , JOB.CHANGE_REASON_NAME
      , JOB.EFFECTIVE_START_DATE
      , JOB.EFFECTIVE_END_DATE
                    from
                        apps.zshr_employee_v EMP
                        , apps.ZSHR_ASSIGNMENT_V JOB
                    where
                        EMP.EMPLOYEE_NUMBER = JOB.EMPLOYEE_NUMBER
                    and TO_CHAR( EMP.EFFECTIVE_END_DATE , 'YYYY-MM-DD')='4712-12-31'                and JOB.QUALIFICATION_CODE <>'0151'
      ORDER BY EFFECTIVE_START_DATE DESC
    CURSOR C_SCM IS        
      SELECT
                        EMP.EMPLOYEE_NUMBER AS EMPLOYEE_NUMBER
      , JOB.BELONGING_NAME
      , JOB.CHANGE_REASON_NAME
      , JOB.EFFECTIVE_START_DATE
      , JOB.EFFECTIVE_END_DATE
                    from
                        apps.zshr_employee_v EMP
                        , apps.ZSHR_ASSIGNMENT_V JOB
                    where
                        EMP.EMPLOYEE_NUMBER = JOB.EMPLOYEE_NUMBER
                   and TO_CHAR( EMP.EFFECTIVE_END_DATE , 'YYYY-MM-DD') ='4712-12-31' and TO_CHAR( JOB.EFFECTIVE_END_DATE , 'YYYY-MM-DD') <'2008-08-01'
      and TO_CHAR( JOB.EFFECTIVE_START_DATE , 'YYYY-MM-DD') >= '1987-07-01'
      and JOB.QUALIFICATION_CODE <>'0151'
      and rownum=1
      ORDER BY EFFECTIVE_START_DATE ASC
    CURSOR C_CM IS        
      SELECT
                        EMP.EMPLOYEE_NUMBER AS EMPLOYEE_NUMBER
      , JOB.BELONGING_NAME
      , JOB.CHANGE_REASON_NAME
      , JOB.EFFECTIVE_START_DATE
      , JOB.EFFECTIVE_END_DATE
            from
                        apps.zshr_employee_v EMP
                        , apps.ZSHR_ASSIGNMENT_V JOB
                    where
                        EMP.EMPLOYEE_NUMBER = JOB.EMPLOYEE_NUMBER
                   and TO_CHAR( EMP.EFFECTIVE_END_DATE , 'YYYY-MM-DD') ='4712-12-31' and TO_CHAR( JOB.EFFECTIVE_START_DATE , 'YYYY-MM-DD') < '1987-07-01'
      and rownum =1
      ORDER BY EFFECTIVE_START_DATE ASC
    -- MAIN BODY BEGINS
    BEGIN
    -- FILE INITIALIZATION
        l_output := utl_file.fopen(MY_FILE_DIR,v_file_handle, 'w', 32767);
    -- WRITING THE FILE HEADER STARTS
        buf := 'EMPLID'
                    || ',EMPL_RCD'
                    || ',EFFDT'
                    || ',EFFSEQ'
                    || ',CX_EE_ID_NBR'
                    || ',CX_SECT_NM'
                    || ',LOCATION'
                    || ',CX_WRK_LOC_DESCR'
                    || ',JOBCODE'
                    || ',JOB_DESCR'
                    || ',GRADE'
                    || ',COMPRATE '
                    || ',CURRENCY_CODE'
                    || ',COMP_FREQUENCY'
        utl_file.put_line(l_output,buf);
    FOR C_EMP_rec in C_MAIN LOOP
    -- CJL LEGACY JOB DATA COLLECTION
    --PS ID EXTRACTION STARTS
      BEGIN
      select PS_ID INTO v_ps_id from apps.TB03569A where
            EBS_ID=C_EMP_rec.EMPLOYEE_NUMBER;
      EXCEPTION
      WHEN no_data_found THEN
      v_ps_id := 'NO DATA';
      END;
    --PS ID EXTRACTION END
      IF  C_EMP_rec.EFFECTIVE_START_DATE >= '2008/8/1' THEN
        buf := v_ps_id                               /* EMPLID */
               || ',' || 0                             /* EMPL_RCD */
               || ',' || C_EMP_rec.EFFECTIVE_START_DATE         /* EFFDT*/
               || ',' || 0                             /* EFFSEQ*/
               || ',' || C_EMP_rec.EMPLOYEE_NUMBER             /* CX_EE_ID_NBR */
                 || ',' || C_EMP_rec.BELONGING_NAME     /* CX_SECT_NM */
                 || ',' || ''                 /* LOCATION */
               || ',' || 'CX_WRK_LOC_DESCR'               /* CX_WRK_LOC_DESCR */
                 || ',' || C_EMP_rec.SG_JOB_CODE /* JOBCODE */
                 || ',' || v_job_descr               /* JOB_DESCR */
                 || ',' || C_EMP_rec.SG         /* GRADE */
               || ',' || ''       /* COMPRATE */
                 || ',' || 'JPY'               /* CURRENCY CODE */
                 || ',' || '' /* COMP FREQUENCY */
                 || ',' || C_EMP_rec.EMP_SG_T_O_FLG           /* SG T Oth. Flag */
      utl_file.put_line(l_output,buf);
      END IF;
    END LOOP;
    FOR C_SCM_rec in C_SCM LOOP
    --PS ID EXTRACTION STARTS
      BEGIN
      select PS_ID INTO v_ps_id from apps.TB03569A where
            EBS_ID=C_SCM_rec.EMPLOYEE_NUMBER;
      EXCEPTION
      WHEN no_data_found THEN
      v_ps_id := 'NO DATA';
      END;
    --PS ID EXTRACTION END
    buf := v_ps_id                               /* EMPLID */
               || ',' || 0                             /* EMPL_RCD */
               || ',' || C_SCM_rec.EFFECTIVE_START_DATE         /* EFFDT*/
               || ',' || 0                             /* EFFSEQ*/
               || ',' || C_SCM_rec.EMPLOYEE_NUMBER             /* CX_EE_ID_NBR */
                 || ',' || C_SCM_rec.BELONGING_NAME     /* CX_SECT_NM */
                 || ',' || ''                 /* LOCATION */
               || ',' || 'CX_WRK_LOC_DESCR'               /* CX_WRK_LOC_DESCR */
                 || ',' || C_SCM_rec.SG_JOB_CODE /* JOBCODE */
                 || ',' || 'v_job_descr'               /* JOB_DESCR */
                 || ',' || C_SCM_rec.SG         /* GRADE */
               || ',' || ''       /* COMPRATE */
                 || ',' || 'JPY'               /* CURRENCY CODE */
                 || ',' || '' /* COMP FREQUENCY */
                 || ',' || C_SCM_rec.EMP_SG_T_O_FLG           /* SG T Oth. Flag */
      utl_file.put_line(l_output,buf);
    -- SCM DATA COLLECTION STARTS
    END LOOP;
    -- SCM DATA COLLECTION ENDS
    FOR C_CM_rec in C_CM LOOP
    --PS ID EXTRACTION STARTS
      BEGIN
      select PS_ID INTO v_ps_id from apps.TB03569A where
            EBS_ID=C_CM_rec.EMPLOYEE_NUMBER;
      EXCEPTION
      WHEN no_data_found THEN
      v_ps_id := 'NO DATA';
      END;
    --PS ID EXTRACTION END
      BEGIN
      select count(*) INTO v_count from
      SELECT 
      distinct
      EMP.EMPLOYEE_NUMBER
      , JOB.ASSIGNMENT_NUMBER
      , JOB.ASSIGNMENT_ID
      from
      apps.zshr_employee_v EMP
      , apps.ZSHR_ASSIGNMENT_V JOB
      where
      EMP.EMPLOYEE_NUMBER=JOB.EMPLOYEE_NUMBER
      and EMP.EMPLOYEE_NUMBER=C_CM_rec.EMPLOYEE_NUMBER
      EXCEPTION
      WHEN no_data_found THEN
      v_count := 0;
      END;
      IF v_count > 1 THEN
      v_job_descr := 'MHI';
      ELSE
      v_job_descr := 'CM';
      END IF;
      buf := v_ps_id                           /* EMPLID */
               || ',' || 0                             /* EMPL_RCD */
               || ',' || C_CM_rec.EFFECTIVE_START_DATE         /* EFFDT*/
               || ',' || 0                             /* EFFSEQ*/
               || ',' || C_CM_rec.EMPLOYEE_NUMBER             /* CX_EE_ID_NBR */
                 || ',' || C_CM_rec.BELONGING_NAME     /* CX_SECT_NM */
                 || ',' || ''                 /* LOCATION */
               || ',' || 'CX_WRK_LOC_DESCR'               /* CX_WRK_LOC_DESCR */
                 || ',' || C_CM_rec.SG_JOB_CODE /* JOBCODE */
                 || ',' || v_job_descr               /* JOB_DESCR */
                 || ',' || C_CM_rec.SG         /* GRADE */
               || ',' || ''       /* COMPRATE */
                 || ',' || 'JPY'               /* CURRENCY CODE */
                 || ',' || '' /* COMP FREQUENCY */
                 || ',' || C_CM_rec.EMP_SG_T_O_FLG           /* SG T Oth. Flag */
      utl_file.put_line(l_output,buf);
    -- SCM DATA COLLECTION STARTS
    END LOOP;
        utl_file.fclose(l_output);
    END;

    Well, I'm not sure what you're issue is as you haven't told us.
    Typically cursors within cursors or multiple cursors are a bad idea, and you should look to try and combine SQL statements into one statement where possible.
    I do however, notice that you've specifying an operating system path for your directory (/usr/tmp2).  You should not use o/s paths with Oracle, you should use Oracle directory objects e.g.
    The UTL_FILE_DIR parameter has been deprecated by oracle in favour of direcory objects because of it's security problems.
    The correct thing to do is to create a directory object e.g.:
    CREATE OR REPLACE DIRECTORY mydir AS 'c:\myfiles';
    Note: This does not create the directory on the file system. You have to do that yourself and ensure that oracle has permission to read/write to that file system directory.
    Then, grant permission to the users who require access e.g....
    GRANT READ,WRITE ON DIRECTORY mydir TO myuser;
    Then use that directory object inside your FOPEN statement e.g.
    fh := UTL_FILE.FOPEN('MYDIR', 'myfile.txt', 'r');
    Note: You MUST specify the directory object name in quotes and in UPPER case for this to work as it is a string that is referring to a database object name which will have been stored in uppercase by default.

  • Multiple Cursors in an OracleResultSet

    Is it possible to iterate over multiple cursors in an OracleResultSet at the same time, or do you have to iterate over a result set (get all the data), then iterate over another resultset (get all the data). See example code 1 and example code 2 below:
    Example Code 1
    =============
    Map output = new HashMap();
              try {
                   // make connection
                   // send JDBC call
                   ResultSet cursor1 = null;
                   while (cursor1.next()) {
                        CartBean chart = new CartBean();
                        cart.setCartName(cursor1.getString("Name"));
                        cart.setCartType(cursor1.getString("Type"));
                        output.put(cart.getCartName(), cart);
                   ResultSet cursor2 = null;
                   while (cursor2.next()) {
                        CartBean chart = (CartBean) output.get(cursor2
                                  .getString("CartName"));
                        Map series = cart.getSeriesData();
                        series.put(cursor2.getString("Label"), new HashMap());
    Example Code 2
    =============
    Map output = new HashMap();
              try {
                   // make connection
                   // send JDBC call
                   ResultSet cursor1 = null;
                   while (cursor1.next()) {
                        CartBean chart = new CartBean();
                        cart.setCartName(cursor1.getString("Name"));
                        cart.setCartType(cursor1.getString("Type"));
                        output.put(cart.getCartName(), cart);
                   ResultSet cursor2 = null;
                   while (cursor2.next()) {
                        Map series = cart.getSeriesData();
                        series.put(cursor2.getString("Label"), new HashMap());
    }

    Hi Nathan,
    I don't full understand your requirements.  It would help if you could give a bit more background information about what you want to achieve.  Assuming you want one row in temp_store_newta for each store, then the following should do it (untested).
    declare
      l_union sdo_geometry;
      l_remainder sdo_geometry;
    begin
      for r1 in (
      select rowid, store_id, client_id, geometry
      from tmcs.tmcs_all_stores_ta
      where client_id = 1
      and rownum < 4)
      loop
      dbms_output.put_line('The primary --> ' || r1.store_id);
      select sdo_aggr_union(sdoaggrtype(geometry, 0.005))
      into l_union
      from tmcs.tmcs_all_stores_ta
      where client_id = 1
      and sdo_anyinteract(geometry, r1.geometry) = 'TRUE'
      and rowid != r1.rowid;
      l_remainder := sdo_geom.sdo_difference(r1.geometry, l_union, 0.005);
      if l_remainder is not null then
       dbms_output.put_line('Inserting the remainder for ' || r1.store_id);
       insert into tmcs.temp_store_newta values (r1.store_id, r1.store_number, r1.client_id, l_remainder);
      else
       dbms_output.put_line('Nothing left after punching out all the other geometries');
      end if;
    end loop r1;
    commit;
    end;
    John

  • Cursor Fetch Loop to Move data from one table to another

    Hi Gurus,
    I need to write a cursor fetch loop PL/SQL procedure that moves all the data from the students table to student_history table. Can anyone tell me how to do this please?
    Thanks

    and the instructions were specific:"Write a PL/SQL procedure that moves all the data from the students table to student_history table. You should use CURSOR FETCH LOOP to retrieve the data"
    Who in the world have given you that instruction? This person[s] should take their ABC learning too. I might have come up with 1001 ineffective and owful ways to perform some task, but to teach others to do it in the same way would be a bit arrogant. To copy the content of a table into another one in CURSOR FETCH LOOP is one of the worst solutions I've heard of. See
    http://asktom.oracle.com/pls/ask/f?p=4950:8:16840616406862738180::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:5008574230335

  • Cursor fetch with multiple rows

    I have been given code which, effectively, looks like this:
    declare
      cursor cTest is select * from (select 'one' from dual union all select 'two' from dual);
      lvText varchar2(10);
    begin
      open cTest;
      fetch cTest into lvText;
      close cTest;
      dbms_output.put_line(lvText);
    end;
    /That consistently returns just the result "one", even though there are two rows in the cursor.
    If I re-write the code like this:
    declare
      lvText varchar2(10);
    begin
      select thecol into lvText from (select 'one' as thecol from dual union all select 'two' from dual);
      dbms_output.put_line(lvText);
    end;
    /...then I get the error I expected (ORA-01422: exact fetch returns more than requested number of rows).
    I guess I am a bit surprised the "fetch into" syntax (which I haven't used before) works at all. Why doesn't it spot that multiple rows are being loaded into a single variable and explode? I am guessing that which row 'wins' the competition to be assigned to the variable is completely indeterminate? Any doco on this behaviour you can point me at, please? The bit I read (http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/fetch_statement.htm) simply says that "You must use either a cursor FOR loop or the FETCH statement to process a multiple-row query", but it doesn't say "the code will silent grab one of the rows at random if you use the FETCH statement on a multiple-row resultset".
    (tested on 11.2.0.3, if it makes a difference)

    >
    I realise FETCH fetches one row. The problem is that without a loop, doing so is 'wrong', logically. But it's still allowed, and I can't find anywhere in the doco that says "if you use FETCH, you MUST loop through the results, otherwise we will only return the first row, which will then probably be a bug in your code".
    I'm asking for something from the doco (or from a website somewhere, maybe) that explains that "fetch without loops will work, but will be wrong". It's not something I expected, put it that way. It's something I would have thought others would have tripped over before now, anyway. In what I've read, like your code example here, you just see fetch-with-loops, with the unstated assumption made that you'd never do it any other way. I've not seen it explicitly said that it's possible to do it without a loop, but would be a dumb thing to do.
    >
    Oracle has no way to know what a developer is trying to do or how many rows a cursor will return.
    It isn't necessarily true that "fetch without loops will work, but will be wrong". My cursor might only return one row.
    What about a BULK COLLECT INTO without a LIMIT clause? Should Oracle tell you that if you query too many records you may run out of memory?
    What about a BULK COLLECT INTO with a limit clause? Should Oracle tell you that "bulk collect with limit without a loop will work, but will be wrong"? It isn't necessarily wrong either.

  • Handling multiple cursors with column of date datatype  issue reg

    Dear all,
    i am using three cursors in one pl/sql block each of this three cursor will fetch data based on column of date data type.i believe due to each condition relate to same table,contradiction may arise i.e
    1> when code will execute , cursor c1 will do the job perfectly but c2 & c3 here may not be able to solve the purpose since the job has already been done by cursor c1 which i am not sure.my doubts i need all cursor to work based on each condition.
    any suggestion from your side could sort out this issues.
    Thanks n regards
    Laxman
    begin
    for c1 in(select reqid from request where lastmoddate<sysdate - 8/24 and statuscode=1 and assigned_personid is not null)loop
    update srequest set status=open where reqid=c1.reqid;
    commit;
    end loop;
    for c2 in(select reqid from request where lastmoddate<sysdate - 1 and statuscode=1 and assigned_personid is null)loop
    update srequest set status=open where reqid=c2.reqid;
    commit;
    end loop;
    for c3 in(select reqid from request where lastmoddate<sysdate - 14 and statuscode=1 and assigned_personid is null)loop
    update srequest set status=open where reqid=c3.reqid;
    commit;
    end loop;

    If you look, your third cursor has already been included in your second cursor (sysdate - 14 < sysdate - 1), so there's only two conditions that you need to run.
    You're also doing row-by-row aka slow-by-slow processing. It would be much, much better (*) if you converted this to one SQL statement - I've rewritten it to be a MERGE statement:
    merge into srequest sreq
    using (select reqid
           from   request
           where  statuscode = 1
           and    ((lastmoddate < sysdate - 8/24
                    and assigned_person_id is not null)
                   or
                   (last_moddate < sysdate - 1
                    and assigned_person_id is null))) req
      on (sreq.reqid = req.reqid)
    when matched then
      update
        set status = 'OPEN';(*) more performant, easier to read, debug and maintain.

  • Reg Open Cursor Concept

    Friends,
    Please kindly help me to analyse this dump.
    In BI end routine select * query has been written to fetch values from active dso . They are using non primary key in the where condition.
    More than 2 crore 20 million records were avaialble in that DSo for that condtion. While executing this query its going to dump.
    If i move ahead with Open cursor set Hold will this query work fine and using open cursor set hold can i fetch  2 crore 20 million records.
    In dump its shwoing to check the parameters : ztta/roll_area  ,ztta/roll_extension and abap/heap_area_total . Even i checked those parametrs in RZ11. The curent val is sufficient.
    Please kindly advice me for this dump and will open cursor set hold avoid the dump for  2 crore 20 million  records.
    Thanks
    Edited by: Suhas Saha on Sep 29, 2011 1:06 PM

    I am not completely convinced:  the difference depends on the task which has to be done with the records of a package.
    If the records are processed and the result must be written to the database into another table, then it will be necessary to COMMIT the changes, otherwise the 20.000.000 records will cause an overflow in the redo-logs of the database.
    => Only the OPEN CURSOR WITH HOLD will survive the DB-Commit.
    The SELECT ... PACKAGE SIZE is simpler and can be used, if the result is further processed and reduced in size, which makes it possible to keep all data in memory (no intermediate DB-COMMITs are necessary) .
    I would assume that case is the less frequent use case.
    Siegfried

  • Return multiple cursors

    I need help in figuring out the best solution for returning data through a package which will contain repeating data from multiple tables. For example
    I have two tables one and two
    one(position,name) and contains
    sales, david
    sales, jane
    marketing, jon
    two (name, product_id) contains
    david, 45
    david, 68
    david, 75
    jane, 1
    the user will input position and i need to return a cursor that will contain all the values in tables one and two where names equal each other. So if a person enters in sales i would need to return
    sales, david, 45
    68
    75
    sales, jane 1
    without repeating position and name over and over.

    You may use two ref cursors
    CREATE OR REPLACE PROCEDURE test_ps (
       in_id         NUMBER,
       cur1    OUT   sys_refcursor,
       cur2    OUT   sys_refcursor
    AS
    BEGIN
       OPEN cur1 FOR
          SELECT 1
            FROM DUAL;
       OPEN cur2 FOR
          SELECT 2
            FROM DUAL;
    END;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Problem with explicit cursor fetching in oracle 8.1.7

    Is there any cursor attribute which can fetch the previous or next record from the cursor using pl/sql.
    thanks in advance

    You would need two cursors. One with > parameter in the where clause order by asc, and one with < parameter in the where clause order by desc. To continue in the same direction keep fetching from the same cursor. To switch directions, close it and open the other one.
    Alternative methods will depend on how much data is involved. You could have one cursor and store the rows already fetched in a pl/sql table. Or you could start off by putting the entire query into a pl/sql table.

  • Reg reference cursor

    First time i am using reference cursors. My question is shall i use cursor For loop for reference cursor inorder to fetch the records. I have defined like this?
    lsql varchar2(1000);
    TYPE L_CurType IS REF CURSOR;
    mm_cursor L_CurType;
    begin
    open mm_cursor for lsql;
    For v_record in mm_cursor loop
    end loop;
    what's wrong in this code? I am getting error at For loop statement after open statement.

    Reference cursors are used for passing a result set to a client, they are not much use in PL/SQL.
    Re: Testing a procedure that returns 2 REF CURSORs
    In databases that are designed for set based processing, loops should be avoded unless you enjoy solving performance problems.
    The performance problems caused by using loops in database code can usually be solved by rewriting the code to use set based processing, such as SQL updates, inserts and deletes, instead of a loop.

Maybe you are looking for

  • Where do i find form and action java files

    I was trying to add a new menuitem to the web console. I have a jsp page like pag1.jsp and has pageForm and pageAction java file. Inside struct.config file I find that form and action files are placed under"com.thortech.xl.webclient.actions.tcAddComm

  • Time Capsule internal HD not detected!

    Hi guys, I've just purchased a Time Capsule 500GB, just got home and pluged it in, all the airport function works well, but I'm not able to detect the hard drive in it at all. Isn't it suppost to be plug and play ? Maybe my unit is defective (I hope

  • OBIEE 11g migration issues...

    Hi Experts, I have installed the OBIEE 11g and tried out the SimpleLite repository and catalog which is available along with the installation. That was working fine. and also I was be able to create/edit the analysis. I could be able to access admin

  • Cannot Update Transitions

    I am working on Final Cut Studio, and have been going along just fine with inserting simple transitions, such as 1 second cross dissolves. Then, when I try to continue doing that, even though I have plenty of footage on either side, the transition in

  • Trigger Outlook  window in WebDynpro

    Hi All, I want to send an email via outlook. Currently I am using LinkToURL component to this by passing the value in reference as “mailto:[email protected]?subject=test” With the above reference value I could pre populate to address as [email protec