How to update multiple records using for loop

Hi I want to update a particular column of few rows in database i had written followin code after that few lines of code and calling action from the task which having commit return ,still it's not updating particular colum.I had debug the code loop is running fine but still changes are not reflecting to database.Let me know if there is any prob with following code snippet.
RealEstatePropertyUnitDetailsVOImpl realEstatePropertyUnitDetailsVO = RealEstatePropertyUnitDetailsVOImpl)realEstateService.getRealEstatePropertyUnitDetailsVO();
for(Row row : realEstatePropertyUnitDetailsVO.getAllRowsInRange())
if("N".equalsIgnoreCase((String)row.getAttribute("RlstdSellYn"))
|| "false".equalsIgnoreCase((String)row.getAttribute("RlstdSellYn")))
row.setAttribute("RlstdAvlblYn", "Y" );
System.out.println("RlsthId "+row.getAttribute("RlstdRlsthId"));
System.out.println("AvlbYN "+row.getAttribute("RlstdAvlblYn"));
System.out.println("RlstdUnitId "+row.getAttribute("RlstdUnitId"));
}

Vishwesh,
I'd start with something along the lines of ...
    RowSet vo = (RowSet)getRealEstatePropertyUnitDetailsVO();
    vo.reset();
    while (vo.hasNext())
      Row row = vo.next();
      row.setAttribute("Attribute", value);
    }getAllRowsInRange() may exclude some rows outside the "range". Also, the vo.reset is needed since your View Object currency may not be at the beginning of your RowSet.
Hope that helps.
Will

Similar Messages

  • Need to update multiple records using store procedure

    Hi i am trying to update multiple records using store procedure but failed to achieve pls help me with this
    for example my source is
    emp_name sal
    abhi 2000
    arti 1500
    priya 1700
    i want to increase salary of emp whose salary is less than 2000 it means rest two salary should get update..using stored procedure only
    i have tried following code
    create or replace procedure upt_sal(p_sal out emp.sal%type, p_cursor out sys_refcursor)
    is
    begin
    open p_cursor for
    select sal into p_sal from emp;
    if sal<2000 then
    update emp set sal= sal+200;
    end i;f
    end;
    and i have called the procedure using following codes
    set serveroutput on
    declare
    p_sal emp.sal%type;
    v_cursor sys_refcursor;
    begin
    upt_sal(p_sal,v_cursor);
    fetch v_cursor into p_sal;
    dbms_output.put_line(p_sal);
    end;
    the program is executing but i should get o/p like this after updating
    1700
    1900
    but i am getting first row only
    2000
    and record is not upsating...please help me with this
    thanks

    Hi Alberto,
    thanx for your valuable suggestion. but still i have doubt. the code which i have mentioned above might be simple but what if i have big requirement where i need update the data by using loops and conditional statement.
    and i have similar kind of requirement where i need to deal with procedure which returns more than one row
    my source is
    empno ename salary
    111,abhi,300
    112,arti,200
    111,naveen,600
    here i need to write a store procedure which accepts the empno (111) as input para and display ename and salary
    here i have written store procedure like this
    create or replace procedure show_emp_det(p_empno in emp.empno%type, p_ename out emp.ename%type,p_salary out emp.salary%type, p_cursor out sys_refcursor)
    is
    begin
    open p_cursor for
    select ename,salary into p_ename,p_salary from emp where empno=p_empno;
    end;
    and i have called this by using
    declare
    p_salary emp.salary%type;
    p_ename emp.ename%type
    v_cursor sys_refcursor;
    begin
    show_emp_det(111,p_ename,p_salary,v_cursor);
    fetch v_cursor into p_ename,p_salary;
    dbms_output.put_line(p_ename);
    dbms_output.put_line(p_salary);
    end;
    here i should get
    abhi,300
    naveen,600
    but i am getting first row only
    abhi,300
    but i want to fetch both rows...pls help me to find the solution

  • How to get multiple records using fn-bea:execute-sql()

    Hi,
    I created Proxy service(ALSB3.0) to get records from DB table. I have used Xquery function(fn-bea:execute-sql()). Using simple SQL query I got single record, but my table having multiple records. Please suggest how to get multiple records using fn-bea:execute-sql() and how to assign them in ALSB variable.
    Regards,
    Nagaraju
    Edited by: user10373980 on Sep 29, 2008 6:11 AM

    Hi,
    Am facing the same issue stated above that I couldnt get all the records in the table that am querying in the Proxyservice.
    For example:
    fn-bea:execute-sql('EsbDataSource', 'student', 'select Name from StudentList' ) is the query that am using to fetch the records from the table called StudentList which contains more than one records like
    Id Name
    01 XXX
    02 YYY
    03 ZZZ
    I tried to assign the result of the above query in a variable and while trying to log the variable, I can see the below
    <student>
    <Name>XXX</Name>
    </student>
    I want to have all the records from my table in xml format but it's not coming up. I get the value only from the first row of my table.
    Please suggest.
    regards,
    Venkat

  • Update Multiple records using NW CE WebDyn Pro 7.2 interface ITEMDETAILS

    We are trying to use SAP Netweaver CE 7.2 and NetWeaver Design Studio 7.2 with the Web Dynpro application interfaces configured to connect to our MDM 7.1 SP06 repositories to develop web screens that allow our end users the ability to maintain MDM repository data without the use of DataManager.
         Our first application was to be a simple one to show the business the benefit of SAP Netweaver. Itu2019s very easy to use the interfaces for SEARCH, RESULTSET, ITEMDETAILS, MATCH and MERGE if you plan to maintain one record at a time. We would like to update many records at the same time.
    Using the configuration described previously, I find that I am able to select multiple records at one time using the RESULTSET interface and the Context folder of u201CSelectedRecordsu201D but I am not able to pass multiple records at one time to the context u201CIODatau201D used by the ITEMDETAILS interface and allow my end users to see and update multiple records at one time.
    If I can pass multiple records from RESULTSET to ITEMDETAILS for display and update would you please provide me with an example of how I would do this in NetWeaver Design Studio for NW CE 7.2..
    If I can NOT pass multiple records from RESULTSET to ITEMDETAILS for display and update, Would I then have to write my own wrapper application to read multiple records selected using the RESULTSET interface and the develop my own UPDATE view to display and update more than one record at a time. This would be time consuming since I would also have to write my own back out procedures and validation of update procedures that already happen within ITEMDETAILS.  Do you happen to have any CE application examples that show how this is done for a NW CE MDM repository that I can see? The current documentation u201CHow to Build Web Applications Using MDM Web Dynpro Components. pdfu201D falls short in the area of updating multiple records.
    Thank you in Advance

    Bugs aside, if it's VERY noisy, that might just be the out-of-sync problem (something I'm very familiar with now).
    Search the forum for "aggregate sync" and you should get some clues, if this is indeed the problem.
    Short of it is, you need to sync the two devices together. Easiest way seems to be to connect the two devices via S/PDIF and set Clock Source to S/PDIF for the "slave" device (set in Audio Midi).
    You can also just set the Clock Source as the "master" device in the drop down, bypassing the need for the S/PDIF cable altogether, but I haven't tried this myself.
    Macbook Pro CD / iMac C2D   Mac OS X (10.4.8)  

  • How to update multiple records checked by check box

    I have list of items in my jsp pages and that are being generated by the following code
    and I want to be able to update multiple records that have a checkbox checked:
    I have a method to update the status and employee name that uses hibernate that takes the taskID
    as a paratmeter to update associated status and comments, but my issue is how to do it with multiple records:
    private void updateTaskList(Long taskId, String status, String comments) {
    TaskList taskList = (TaskList) HibernateUtil.getSessionFactory()
                   .getCurrentSession().load(TaskList.class, personId);
    taskList.setStatus(status);
    taskList.setComment(comments);
    HibernateUtil.getSessionFactory().getCurrentSession().update(taskList);
    HibernateUtil.getSessionFactory().getCurrentSession().save(taskList);
    <table border="0" cellpadding="2" cellspacing="2" width="98%" class="border">     
         <tr align="left">
              <th></th>
              <th>Employee Name</th>
              <th>Status</th>
              <th>Comment</th>
         </tr>
         <%
              List result = (List) request.getAttribute("result");
         %>
         <%
         for (Iterator itr=searchresult.iterator(); itr.hasNext(); )
              com.dao.hibernate.TaskList taskList = (com.dao.hibernate.TaskList)itr.next();
         %>     
         <tr>
              <td> <input type="checkbox" name="taskID" value=""> </td>
              <td>
                   <%=taskList.empName()%> </td>           
              <td>          
                   <select value="Status">
                   <option value="<%=taskList.getStatus()%>"><%=taskList.getStatus()%></option>
                        <option value="New">New</option>
                        <option value="Fixed">Fixed</option>
                        <option value="Closed">Closed</option>
                   </select>          
    </td>
              <td>               
                   <input type="text" name="Comments" MAXLENGTH="20" size="20"
                   value="<%=taskList.getComments()%>"></td>
         </tr>
    <%}%>
    _________________________________________________________________

    I solved it by making changes in the occurrence  parameter of data type ...:-)

  • How to Delete Multiple Records using selectbox in jsf

    Hi!
    My Senario is I want to delete multiple records using checkbox. After selecting multiple records when i click the delete button the selected
    rows shuld be deleted.if am doing like this but the edit ,delete for each row functionality is not working.
    <h:selectBooleanCheckbox id ="bcb" value="#{item.empno}">
    </h:selectBooleanCheckbox>
    But other functionality is not wokring.
    Can any one plz tell how to select the multiple records and how to send the id to the serverside.
    I want code code for jsp and as well as backingBean how to accaess .
    Any Reply shuld be apreciated

    You may find this article useful as well: http://balusc.blogspot.com/2006/06/using-datatables.html
    Check the chapter "Select multiple rows" for two generic ways to select multiple rows in a datatable.

  • How to update multiple records in Oracle ?

    Hi Guys,
    <b>I have to update multiple records from a file into Oracle Table...</b>
    I can successfully insert the multiple records into the table but can't update the multiple records into the table.
    when i am using UPDATE_INSERT only my first record of the file is getting updated in th e table..
    Please share your views with me.
    Regards,

    I solved it by making changes in the occurrence  parameter of data type ...:-)

  • How to update multiple records in the table using POST parameters:

    i got this idea from this website:http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-s ingle-sql-query/comment-page-1/#comment-5409. Basically i am trying to update all the status in the results page, and by adding $i in front of the id in the text fields, and checkboxes, i can name the different inputs with different names:
    The image of how it takes the inputs is shown here:http://forums.adobe.com/thread/709034?tstart=0
    I tried this but got this error:Parse error: syntax error, unexpected T_IF, expecting ')' in C:\xampp\htdocs\Database Query\results_change.php on line 51
    will not work in the update code section:
    for($i=0;$i<$maxRows_Recordset1;$i++)
    {$a=sprintf("%s",GetSQLValueString($_POST['changeid $i'],"int"));
    $b=sprintf("%s",GetSQLValueString($_POST['checkbox $i'],"text"));
    $display_order .= array(
        $a => $b
    if($i<$maxRows_Recordset1-1)
    $ids = implode(',', array_keys($display_order));
    $updateSQL = "UPDATE `change` SET Status = CASE Change_id ";
    foreach ($display_order as $a => $b) {
        $updateSQL .= sprintf("WHEN %d THEN %s ", $a,$b);
    $updateSQL .= sprintf("END WHERE `Change_id` IN ($ids)");

    Hi,
    Try
    BEGIN
      FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
        UPDATE xx_test
        SET checkbox = 'Y'
        WHERE rec_no = APEX_APPLICATION.G_F03(i);
      END LOOP;
    END;Code loops all checked checkbox. You do not need commit on page process.
    Regards,
    Jari
    http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0

  • How to update multiple records in custom table using checkbox in APEX 4.1?

    Hi,
    I have a SQL report which brings up all the data records using the following query.
    select
    "REC_NO" AS hidden_rec_no,
    "REC_NO",
    APEX_ITEM.CHECKBOX (3,rec_no) AS edit,
    "MEETING_TYPE",
    "PAGE_NO",
    "CHECKBOX"
    from "XX_TEST" m
    WHERE page_no = :p_page_no
    Out of all records, any records which are checked, I only want to update their flag to 'Y' on the database column "Checkbox". For this, I have a SUBMIT button on the report region. The processing code on pressing the SUBMIT button is:
    DECLARE.
    l_row NUMBER := 1;
    BEGIN
    FOR i IN 1..APEX_APPLICATION.G_F03.COUNT
    LOOP
    FOR j IN l_row..APEX_APPLICATION.G_F01.COUNT
    LOOP
    IF APEX_APPLICATION.G_F01(j) = APEX_APPLICATION.G_F03(i) THEN
    UPDATE xx_test
    SET checkbox = 'Y', -- APEX_APPLICATION.G_F03(j)
    WHERE rec_no = APEX_APPLICATION.G_F03(i);
    l_row := j + 1;
    EXIT;
    END IF;
    END LOOP;
    END LOOP;
    COMMIT;
    END;
    However, that is not happening. Please help me with this. Any solutions/suggestions are most welcome.
    Regards.

    Hi,
    Try
    BEGIN
      FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
        UPDATE xx_test
        SET checkbox = 'Y'
        WHERE rec_no = APEX_APPLICATION.G_F03(i);
      END LOOP;
    END;Code loops all checked checkbox. You do not need commit on page process.
    Regards,
    Jari
    http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0

  • Update Multiple Records Using ASPVBscript

    I am trying to display multiple records on a page with a
    checkbox for each record, the checked value = Y. Then select
    multiple checkboxes and update each record at one time. I am using
    MS SQL as my DB. Is there an extention or command that I can use to
    accomplish this. Can anyone help.
    Thanks

    You need to give distinct values to your checkboxes and value
    fields. This
    can be done inside the DW Repeat Region loop code as it
    generates the rows.
    You then set another loop for the update. It is quite
    straightforward
    really.
    Have a look at Julian's site, here:
    http://www.charon.co.uk/content.aspx?CategoryID=27&ArticleID=41
    Also, there are a couple of links at the bottom of the above
    page. They use
    slightly different approaches and are usefull too.
    "StarM3d" <[email protected]> wrote in
    message
    news:f470in$p4v$[email protected]..
    >I am trying to display multiple records on a page with a
    checkbox for each
    > record, the checked value = Y. Then select multiple
    checkboxes and
    > update
    > each record at one time. I am using MS SQL as my DB. Is
    there an
    > extention or
    > command that I can use to accomplish this. Can anyone
    help.
    >
    > Thanks
    >
    >

  • Update multiple records using checkbox

    Hi All,
    I have one requirement related to multiple record update using checkbox.
    HTML form has 6 columns and many rows.
    Now i want to update all 6 columns in the table for selected checkbox.
    Can any body give me some idea/code about this.
    Thanks in advance.
    Ravi

    I did not understand your idea.
    multiple columns can be updated as follows...
    update table set col1=value,col2=value,col3=value where conditions;
    We are using adodb driver in our environment. So I will explain concern to it. Store all the form new values in $var array and you can pass this $var to query execution.
    A vague idea
    $rs = $conn->Execute($update_sql,$var);     
    if ($rs===false) die('DB Error: '. $conn->ErrorMsg() );

  • How to update multiple records in a table created in view (web dynpro)

    Here is my coding......
    *coding to get the district value
    DATA lo_nd_district TYPE REF TO if_wd_context_node.
        DATA lo_el_district TYPE REF TO if_wd_context_element.
        DATA ls_district TYPE wd_this->element_district.
        DATA lv_district_txt LIKE ls_district-district_txt.
      navigate from <CONTEXT> to <DISTRICT> via lead selection
        lo_nd_district = wd_context->get_child_node( name = wd_this->wdctx_district ).
      get element via lead selection
        lo_el_district = lo_nd_district->get_element(  ).
      get single attribute
        lo_el_district->get_attribute(
          EXPORTING
            name =  `DISTRICT_TXT`
          IMPORTING
            value = lv_district_txt ).
    *coding to diplay records when clicking a button(Submit)
    DATA lo_nd_table TYPE REF TO if_wd_context_node.
    DATA lo_el_table TYPE REF TO if_wd_context_element.
    DATA ls_table TYPE wd_this->element_table.
      DATA lv_district LIKE ls_table-district.
    navigate from <CONTEXT> to <TABLE> via lead selection
      lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
    get element via lead selection
      lo_el_table = lo_nd_table->get_element(  ).
    get single attribute
      lo_el_table->set_attribute(
        EXPORTING
          name =  `DISTRICT`
       " IMPORTING
          value = lv_district_txt ).
    The above coding updates only one record to that
    table created in view.
    If i enter 2nd district value means then the first record
    in the table is overwritten.
    So my need is the record should not be overwritten.
    it(2nd record ) should be displayed after the 1st record.
    Any one can help me and send the coding plz....

    instead of using set attribute you should use bind table method to display/update the records in table view.
    step1 ) collect all the data in a local table
    step2 ) and the bind that lacal table with your node
    search1 = wd_context->get_child_node( name = `TABLE1` ).
    search1->bind_table( lt_detail)
    here lt_detail is your local table and TABLE1 is node which is bound with table ui element.

  • How to create multiple records using ADF

    Currently working on my first ADF BC and UIX project, and I basically want to create multiple records after a user makes a choice on the screen. I would like to know at what layer should this functionality be implemented?
    Would this be more at the Struts/Controller level, where I have a java class to perform the creation as part of a data action? I ask because, I am not sure if this is feasible at the ADF BC level (View objects and Entity Objects) via some sort of customization, and i am new to the different possibilies avail as part of the ADF framework
    Regards
    Anora
    (Jdeveloper 10.1.2.1 build 1913, Oracle DB 10.1.2)

    I'd put it into the application module. You then can call the method from the controller layer or from an other application module. This way you put it into the business logic, which helps if you ever decide to use a different client approach (like swing).

  • How to update multiple records in a table using procedure?

    Dear All,
    1 am using 11.1.2.1.0
    my question is i have a table like
    emp id(primary key), empname,location
    1                             damby      blore
    2                             rocky       kormangala
    3                              biswa     india
    my question  is i need to write one procure that at a time i can update empname and location(wat the value are there in empname and location i  need to change at a time).
    thanks
    Damby

    Hi, Damby,
    That sounds like what the UPDATE statement does, exactly.  Just use an UPDATE statement to change any number of columns in existing rows.  You don't need a procedure, but, if you're using a procedure for some other reason, you can do the UPDATE in the procedure.  UPDATE works the same in SQL or PL/SQL.
    Sometimes MERGE is more convenient than UPDATE.  Like UPDATE, it can change any number of columns, either in SQL or PL/SQL.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to update multiple tables using results from query

    I'm a bit rusty on this stuff and am hoping for some help.
    Table 1 is:
    location_id, location_name
    Table 2 is
    location_id, employee_id and misc. other columns
    Then there are multiple tables with associated data, keys being location_id and employee_id.
    There are no established relationships.
    Trying to come up with a process to change location_id for all employees assigned to a particular location.
    It seems to me that the basics are
    select employee_id from Table2 where location_id='xxxxxx'
    Then take each employee_id returned and change their location_id in each of the other tables
    I'm not clear on how to load the returned employee id's as variables and then loop through them.
    Thanks

    Thanks for the welcome. I'll read up on the rules now.
    Below is the DDL for a couple of the tables.
    Version = 11g
    I would query the users table for all users with a certain site_id and then use them to update the site_id in the users table (and other tables)
    -- DDL for Table USERS
    CREATE TABLE "USERS"
    (     "USERID" VARCHAR2(8 BYTE),
         "PASSWORD" VARCHAR2(50 BYTE),
         "FIRST_NAME" VARCHAR2(50 BYTE),
         "LAST_NAME" VARCHAR2(50 BYTE),
         "SITE_ID" VARCHAR2(5 BYTE),
         "ROLE_ID" VARCHAR2(1 BYTE)
    ) SEGMENT CREATION IMMEDIATE
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "SITES_DATA_TS"
    CACHE ;
    -- DDL for Table EMPLOYEE_PROFILE
    CREATE TABLE "EMPLOYEE_PROFILE"
    (     "EMPLOYEEID" VARCHAR2(9 BYTE),
         "PROGRAM" NUMBER,
         "REQUIREMENT" NUMBER,
         "JOBNUM" VARCHAR2(50 BYTE),
         "STATUS" VARCHAR2(50 BYTE),
         "PROGRAM_TYPE" VARCHAR2(50 BYTE),
         "SITE_ID" VARCHAR2(5 BYTE),
         "NUM_QUAL_TEST_ATTEMPTS" NUMBER(7,0)
    ) SEGMENT CREATION IMMEDIATE
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "SITES_DATA_TS"
    CACHE ;

Maybe you are looking for