Modify Rows in Cursor

How can i Modify rows in a Cursor?
i want to loop through cursor records and update rows on sepcific condition and update one field .and put back in the cursor.
Suggest Some way to achieve this.

you can only modify values of rows within the cursor when the values in the cursor are fetched and then looped through.
Once the fetch is over and you modify some values the values are not permenant. If you open the cursor again then old values will be fetched.
eg:
SQL> DECLARE
  2     CURSOR c1
  3     IS
  4        SELECT 1 AS col1, 2 AS col2
  5          FROM DUAL
  6        UNION ALL
  7        SELECT 3 AS col1, 4 AS col2
  8          FROM DUAL;
  9  BEGIN
10     FOR i IN c1
11     LOOP
12        DBMS_OUTPUT.put_line ('col1--->'||i.col1);
13        i.col1 := 10;
14        i.col2 := 20;
15        DBMS_OUTPUT.put_line ('col1--->'||i.col1);
16        DBMS_OUTPUT.put_line ('col2--->'||i.col2);
17     END LOOP;
18  END;
19  /
col1--->1
col1--->10
col2--->20
col1--->3
col1--->10
col2--->20here col1 value is modified and if you are doing further processing inside the loop for that record then 10 will avaliable and not 1. But if i again open the cursor and loop through 1 will be the value.
Hope it makes sense...
Edited by: [email protected] on May 11, 2010 5:29 AM

Similar Messages

  • Excel - Modify rows without touching other data (have gone thru LV report generation 4 designs)

    File attached....
    Have gone thru FAQs and examples. (And also 4 parts of 'Creating a Report in Microsoft Excel Using the LabVIEW Report Generation Toolkit'. Unfortunately this document is not clear enough for me.)
    Have task of modifying rows of the same excel sheet, number of times without touching data  already present (numbers and strings)
    I have an excel file. (attached)
    A test will be run N number of times.  (N<=17)
    SubTask 1 --> Each time it runs, string data needs to be placed in 'n'th row. (...there are going to be notes in Row 18 and row 19)
    SubTask 2  --> Each time it runs, a 1D array data also will be placed in the same row (but in different cells)
    SubTask 3 --> The number 'n' of the row (where to place the current iteration's data) needs to be determined on fly (by looking at "n-1"st non blank row)
    The same file needs to be used.
    How can above be achieved ?
    thnks
    Sandeep
    Attachments:
    sample excel file.xls ‏14 KB

    See if this board will help.
    http://forums.ni.com/ni/board/message?board.id=BreakPoint&message.id=2391

  • How to modify a system cursor in my application?

    Hello to all!
    It's possible to modify the system cursor as a wait cursor for all my application?
    I have read only Component.setCursor, but i need a fast mode for setCursor in ALL my application components...
    Thanks for responses

    Set the cursor for your root frame to a wait cursor. That should do it.

  • How to get the total count of the no. or rows a cursor has fetched

    Hi All,
    Is there a way to get the number of rows a cursor query has fetched, without looping into the cursor and using a counter variable
    I mean like in pl/sql table we can directly use the pl/sql table attribute .count is there a way to achieve this in cursor
    thanks a lot in advance

    Qwerty wrote:
    Is there a way to get the number of rows a cursor query has fetched, without looping into the cursor and using a counter variableYes.
    It is zero.
    On the first loop and first fetch it will be 1, second 2 etc.
    This is because cursors have no rows, or fetch no rows until your code or the client uses the cursor to fetch them.
    I mean like in pl/sql table we can directly use the pl/sql table attributeA PL/SQL array is not like a cursor, a PL/SQL array has the rows already fetched into it.
    A cursor is not an array but a pointer to a compiled SQL statement so you cannot count how many rows it has, because it has none. You can only count how many rows you fetch from it.

  • How to save the modified rows in jspx page usind adf default commit action

    Hi,
    We are displaying some columns of the database table in jspx page. Here we are using adf commit action to save these values to database which is updating all the rows by default. In this page there are some editable columns which the user can miodify. How can we update only these modified rows using default adf commit action. Also we want to update last_updated_date column of that particular row which is modified in the UI from backing bean .
    Can anyone please help us in solving this.
    Thanks in advance

    User,
    A key question - what are you using for the model layer (ADF Business Components, JPA, EJB, etc)?
    How are you determining that a "commit" action is updating rows (even those which haven't changed)?
    If you are using ADF Business Components - have a read in the documentation about history columns - the use case you describe (updating the last_udpdated_date column) is supported "out-of-the-box" for this.
    John

  • How to highlight a modified row in module pool

    hi frnds,
         Is it possible to highlight a row that is modified in a  ztable using module pool...

    I have created a ztable-'zpk_table' from which i take the values  n pass it to an internal table-'itab'...
    i modify these values using a modify screen created in module pool..
    after modifying i want the modified row to be highlighted in the next table control screen...

  • APEX don't allow modify rows in columns which are Primary Key ?

    I have tables:
    http://img508.imageshack.us/my.php?image=21269582oe8.jpg
    book(id_book - "Primary Key", title, year); book_author(id_book - "Primary Key", id_author - "Primary Key"); author(id_author - "Primary Key", name)
    I have created a new page -> Form -> Tabular Form for table 'author' because I would like to add new authors, modify and delete. During creating this page I have choosen column 'id_author' as 'primary key column 1' and everything is OK (I can't modify column 'id_author' - this column is autoincrement and I can modify column 'name').
    BUT I have also created a new page -> Form -> Tabular for table 'book_author' because I would like to write numbers as id_book and id_author, modify and delete them (so add relations between tables: book, book_author and author). During creating this page I have choosen column 'id_book' as 'primary key column 1' and 'id_author' as 'primary key column 2'. And on website I can't modify (edit) these fields. And I can't also add new row because I see in each column in new row: (null).
    http://img444.imageshack.us/my.php?image=11324615yk9.jpg
    APEX don't allow modify rows in columns which are Primary Key ? This is stupid....... What can I do ?
    Edited by: user10731158 on 2008-12-20 11:40

    Single-column and non-meaningful so you never want to update them. In the case of your example, you would need to add an ID column to the book_author intersection table. Honestly, I was so blown away (and pleasantly surprised) by the lack of rebuttal and the "thx" that I went ahead and put together an example of how I would define the book_author table:
    create table  book_author
       (id varchar2(32),
        book_id varchar2(32),
         author_id varchar2(32),
         modified_on     date,
         modified_by varchar2(255),
         constraint book_author_pk primary key (id),
         constraint book_auth_book_fk foreign key (book_id) references books(id),
         constraint book_auth_author_fk foreign key (author_id) references authors(id)
    create unique index book_author_uq on book_author (book_id,author_id)
    create or replace trigger  biu_book_author before insert or update on book_author
    for each row
    begin     
         if inserting then
              :new.id := sys_guid();
         end if;
         modified_on := sysdate;
         modified_by := nvl(v('APP_USER'),user);
    end;
    /Good luck,
    Tyler

  • How to track modified rows in ALV list

    I need to keep track of all the rows in the ALV list that the users have modified.  When the user selects SAVE, I need to read the modified rows and save the changes to the database.  I thought I could use mp_mod_rows but I cannot get the syntax and the variable declarations correct. 
    Thanks.
    Sandy

    Hi,
    R u using FM or.............
    If u r using FM look at my example.....
    data: LC_GLAY TYPE LVC_S_GLAY.
    LC_GLAY-EDT_CLL_CB = 'X'.<<<<<------
    gt_layout-zebra = 'X'.
    gt_layout-detail_popup = 'X'.
    gt_layout-colwidth_optimize = 'X'.
    ITAB1[] = ITAB[].<<<<<-----make a copy of ITAB for further comparision.
    call function 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = i_repid
    i_callback_user_command = 'USER_COMMAND1'
    it_fieldcat = header
    is_layout = gt_layout
    i_callback_top_of_page = 'TOP-OF-PAGE1'
    i_grid_title = text-h17
    it_sort = gt_sort[]
    i_default = 'X'
    i_save = 'U'
    is_variant = gt_variant
    it_events = gt_events
    I_GRID_SETTINGS = LC_GLAY<<<<<<------
    TABLES
    t_outtab = itab.
    clear itab.
    Form USER_COMMAND1
    FORM USER_COMMAND1 USING u_ucomm LIKE sy-ucomm
    us_selfield TYPE slis_selfield."#EC CALLED
    case u_ucomm.
    when '&DATA_SAVE'.<<<<<<<<----
    This will come after the data was EDITTED and when SAVE was clicked by user in output scren.
    Here now in the final internal table(ITAB) you can find the data changed in EDIT mode.
    After this you can do manipulation what ever you want.
    Thanks.
    If this helps you reward with points.

  • Number of rows in cursor

    I believe this might have been asked multilpe times, but I could not find anything.
    Is there any way to get the number of rows in a cursor, when I open the cursor. In my case, I have to do the processing in 3 different ways depending on whether the cursor has A)no rows, B) One row, c) more than one row. I know I can get the number of rows by fetching all the rows and then getting the %rowcount.
    I wanted to know whether its possible before fetching any row. The ways I am currently doing it is as follows
    blah blah blah is
    Cursor cur = <my cursor query>;
    cont number;
    BEGIN
    select count(*) into cont from <things exactly same as my cursor query>
    if (cont = 0) THEN
    <Processing A>
    ELSIF (cont = 1) THEN
    <Processing B>
    ELSE
    <Processing C>
    END IF;
    END
    Is this method better than getting the the cursor, fetching at least 2 rows, if the rowcount is more than one, close the cursor and do the processing based on the rowcount i've got.
    TIA

    create or replace
    package Y1 is
       procedure do_it (p_1 number) ;
    end Y1;
    create or replace
    package body Y1 is
       procedure do_it (p_1 number) is
          cursor c1_cur (p_1 number) is
            select tname from tab where rownum <= p_1
          c1_rec c1_cur%rowtype ;
          c2_rec c1_cur%rowtype ;
          l_count  number ;
       begin
          l_count  := 0 ;
          open c1_cur(p_1) ;
          LOOP
             if l_count = 0 then
                fetch c1_cur into c1_rec ;
             else
                fetch c1_cur into c2_rec ;
             end if ;
             exit when c1_cur%notfound ;
             l_count  := l_count + 1 ;
             if l_count = 2 then
                dbms_output.put_line ('XXX=2') ;  
                dbms_output.put_line (c1_rec.tname) ;
                dbms_output.put_line (c2_rec.tname) ;
             elsif l_count > 2 then
                dbms_output.put_line ('XXX>2') ; 
                dbms_output.put_line (c2_rec.tname) ;
             end if ;
          END LOOP ;
          close c1_cur ;
          if l_count = 0 then
             dbms_output.put_line ('XXX=0') ;
             dbms_output.put_line ('===========================') ;
          elsif l_count = 1 then
             dbms_output.put_line ('XXX=1') ;
             dbms_output.put_line (c1_rec.tname) ;
             dbms_output.put_line ('===========================') ;
          else
             dbms_output.put_line ('===========================') ;
          end if ;
       end do_it ;
    end Y1;
    SQL> set serveroutput on
    SQL> exec Y1.do_it (0)  -- etc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Count Rows in cursor

    How I can count number of rows in a cursor?. In other words, how I can count how many records set in one cursor

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by quang dau ([email protected]):
    How I can count number of rows in a cursor?. In other words, how I can count how many records set in one cursor <HR></BLOCKQUOTE>
    Hi
    You can use c1%rowcount where c1 is name of cursor.
    good luck
    Kavita
    null

  • Specify the number of rows in Cursor

    Hi,
    Can anyone tell me, if there is some way where i can specify the number of rows to be fetched in a single cursor.
    As in, The first fetch 100 rows, second 100 and so on
    Regards,
    Rishav

    Hi
    Use the option PACKAGE
    FETCH NEXT CURSOR <CURSOR> INTO TABLE <int table> PACKAGE SIZE 100.
    Max

  • Getting current row or cursor

    Hi all,
    I'm using FM 'REUSE_ALV_GRID_DISPLAY' in my program. However, I'm having problem getting the current row or the cursor position in my ALV. If possible, I do not wish to use OO method in doing this. Is there any other way?

    Hello Mil,
    When u double click a row we can able to capture the column value field name every thing.#
    Check this.
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                      RS_SELFIELD TYPE SLIS_SELFIELD.
      CHECK RS_SELFIELD-FIELDNAME = 'VBELN_O' OR
            RS_SELFIELD-FIELDNAME = 'VBELN'.
      CASE R_UCOMM.
        WHEN '&IC1'.   "doubleclick
          SET PARAMETER ID 'AUN' FIELD RS_SELFIELD-VALUE.
    *      IF RS_SELFIELD-FIELDNAME = 'VBELN_O'.
          IF RS_SELFIELD-FIELDNAME = 'VBELN_O'.
            IF  NOT  RS_SELFIELD-VALUE IS INITIAL.
              CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
            ELSE.
              MESSAGE E999(Z48MM) WITH TEXT-T02 SPACE SPACE SPACE.
            ENDIF.
          ELSEIF RS_SELFIELD-FIELDNAME = 'VBELN'.
            PERFORM CALL_TRANSACTION_VA23 USING RS_SELFIELD-VALUE.
    *        CALL TRANSACTION 'VA23' AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
    ENDFORM.                    " USER_COMMAND

  • How to include new inserted row in cursor

    Hi ...
    Is there anyway to include new inserted row into opened cursor ?
    consider the following code:
    declare
    cursor tbl_cur is select * from table1;
    -- table1 has two fields: no and name --
    begin
    for tbl_rec in tbl_cur
    loop
    -- if I insert some records here into table1, is there anyway that those just inserted records be included in tbl_cur so that can be proceed in for loop ? or anyway to include new inserted rows into opened cursor ?
    end loop;
    end;
    anyone response is highly appreciated.
    Thank You,
    SK.
    null

    If you re-open the cursor in another loop, the rows that you inserted in the previous loop will be included, along with the original rows.
    DECLARE
    CURSOR tbl_cur
    IS
    SELECT *
    FROM table1;
    BEGIN
    FOR tbl_rec IN tbl_cur
    LOOP
    INSERT INTO table1 (no, name)
    VALUES (tbl_rec.no + 1, 'test');
    END LOOP;
    FOR tbl_rec IN tbl_cur
    LOOP
    -- the rows you inserted in the loop
    -- above will be included here
    -- with the original rows
    END LOOP;
    END;
    null

  • Maximu number of rows in cursor

    Hi,
    How many rows i can fetch into the cursor.
    is there any restriction.
    when the number of rows increase will the db face the slowness?
    Thanks
    siva

    thanks
    this is my code
    CREATE OR REPLACE PROCEDURE PRC_FILE_UPLOAD(n_eodid NUMBER,job_id NUMBER,return_status OUT VARCHAR2) IS
    n_col          NUMBER(10);
    n_colcnt      NUMBER(10) :=0 ;
    v_eodmetadata     EOD_METADATA_DET%ROWTYPE;
    v_eodtable     VARCHAR2(100);
    sql_stmt      VARCHAR2(4000);
    sql_stmt1      VARCHAR2(4000);
    colval      varchar2(4000);
    eodid          NUMBER(10) := n_eodid;
    jid          NUMBER(10) := job_id;
    charbuf VARCHAR2(4000);
    lopcnt     NUMBER(10) :=0 ;
    s          NUMBER(10) :=0 ;
    vals          VARCHAR2(4000);
    no_data      EXCEPTION;
    result     VARCHAR2(100);
    CURSOR clob_ins IS SELECT * FROM EOD_METADATA_DET WHERE eod_id = EODID
    AND UPPER(ORCL_COL_NME) !='FILLER' ORDER BY SEQ;
    BEGIN
    OPEN clob_inS;
    LOOP
    FETCH clob_ins INTO v_eodmetadata;
         v_eodtable := v_eodmetadata.orcl_tbl_nme;
    EXIT WHEN clob_ins%notfound;
    colval := colval||' '||v_eodmetadata.ORCL_col_NME||',' ;
    n_col := v_eodmetadata.col_size;
    END LOOP;
    sql_stmt := 'INSERT INTO '||v_eodtable||'(';
    sql_stmt1 := sql_stmt||COLVAL;
    sql_stmt1 := SUBSTR(sql_stmt1,1,LENGTH(sql_stmt1)-1)||')VALUES';
    CLOSE clob_ins;
    FOR jval IN (SELECT * FROM EOD_FLAT_DATA)
    LOOP
    lopcnt := 0;
    n_colcnt :=0;
    s:=s+1;
    IF s <= 1 THEN
    s:=s+1;
    ELSE /* from second row onwards */
    charbuf := jval.EODDATA;
    FOR seq IN (SELECT col_size,TYPE FROM EOD_METADATA_DET WHERE eod_id = EODID AND UPPER(ORCL_COL_NME) !='FILLER'
    ORDER BY SEQ)
    LOOP
    n_col := seq.col_size;
    lopcnt := lopcnt + 1;
    IF lopcnt = 1 THEN /* for first column WIDTH */
    vals := SUBSTR(charbuf,1,n_col);
    n_colcnt := n_colcnt + n_col;
    ELSE
    IF seq.type = 'CHAR' THEN
    vals := vals||','||''''||SUBSTR(charbuf,n_colcnt+1,n_col)||'''';
    ELSIF seq.type = 'NMBR' THEN
    vals := vals||','||SUBSTR(charbuf,n_colcnt+1,n_col);
    ELSIF seq.type = 'DATE' THEN
    VALS := vals||','||''''||to_char(to_date(SUBSTR(charbuf,n_colcnt+1,n_col),'dd/mm/RR'),'dd-mon-yyyy')||'''';
    ELSE
    vals := vals||','||''''||SUBSTR(charbuf,n_colcnt+1,n_col)||'''';
    END IF;
    n_colcnt := n_colcnt + n_col;
    END IF;
    END LOOP;
    END IF;
    IF length(vals)>1 THEN
    sql_stmt1 := sql_stmt1||'('||vals||')';
    EXECUTE IMMEDIATE sql_stmt1;
    return_status := 'SUCCESS';
    result := return_status;
    END IF;
    END LOOP;
    EXCEPTION
    WHEN DUP_VAL_ON_INDEX THEN
    return_status := 1;
    result := return_status;
    RAISE_APPLICATION_ERROR(-20010,'UNIQUE CONSTRAINT VIOLATION ERROR');
    WHEN OTHERS THEN
    return_status := 'FAILED';
    result := return_status;
    RAISE_APPLICATION_ERROR(-20010,'CHECK UR INSERT STATEMENT');
    END PRC_FILE_UPLOAD;

  • [SOLVED] get modified row

    Hi,
    I'm using JSF, ADF BC, I have master detail relationship, for detail I'm using ADF table through which I'm changing detail data, on commit I want to delete all rows that WERE NOT modified. how can I do it, is there a method that returns rows that have been modified in entity object, or something similar.
    Thanks in advance,
    Tomislav
    Message was edited by:
    thundric

    Hi,
    see http://www.oracle.com/technology/products/jdev/tips/muench/mostcommon/index.html#businesstierentity
    "Determine the state of the entity instance, irrespective of whether it has already been posted in the current transaction (but not yet committed)
    getEntityState()
    Note:      
    Will return one of the constants STATUS_UNMODIFIED, STATUS_INITIALIZED, STATUS_NEW, STATUS_MODIFIED, STATUS_DELETED, or STATUS_DEAD indicating the status of the entity instance in the current transaction. "
    Frank

Maybe you are looking for

  • I can't install Intel graphics driver for HP Pavilion G6 2240SH under Windows 8.1

    HI! I installed Windows 8.1 Update 1 x64 to my HP Pavilion G6 2240SH laptop. I started install the drivers and I got an error message in the Intel High-Definition setup: "This computer does not meet the minimum requirements for installing the softwar

  • BPM Error: BPE_ADAPTER MESSAGE_NOT_USED

    Hi, we have an issue in our XI production system, where message is not reaching BPM and its giving below error.   <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> - <!--  Call Adapter   --> - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message

  • Diagnostic mode--battery or board?

    I have a first generation Nano with a short battery life. Is there a way of using the diagnostic mode to determine if it is due to a battery gone bad or if it is due to a hardware problem? What do the results mean in the power test?? The Nano seems t

  • Oracle Retail Products Installation and Implementation

    Can individual modules like Oracle Retail Allocation be used as standalone Products, without installing Oracle RMS? The following point is mentioned in the Oracle® Retail Merchandising Implementation Guide Release 13.2.4 E28940-01 "RMS owns virtually

  • Clone stamp tool help / Nobody can help me!

    OK so here is my problem, i have been serching and posting this on every forum on adobe i can find, and still nobody can help me! Im getting so frustrated! Ok I'm editing this image and I would like to use the clone stamp tool to color something the