Deleting a single row from a dataTable / database

Hi,
I am fairly new to JSF so please bear with me if the answer is obvious :D. I'm using a dataTable component to display data from a database and would like to add a commandLink component to every row in the table that deletes that row from the database. What is the most effective way of doing this?
I'm thinking of using a ListDataModel with some function that removes the correct row (though I'm not sure how it will tie in with a commandLink and exactly where the database will be updated). I'll appreciate any pointers or perhaps even an online example of something similar.
Alternatively I suppose you could pass an "id" parameter on with the commandLink that somehow gets read in the request and the appropriate row is removed accordingly. This solution seems cumbersome however.

jabalsad wrote:
Hi,
I am fairly new to JSF so please bear with me if the answer is obvious :D. I'm using a dataTable component to display data from a database and would like to add a commandLink component to every row in the table that deletes that row from the database. What is the most effective way of doing this?
I'm thinking of using a ListDataModel with some function that removes the correct row (though I'm not sure how it will tie in with a commandLink and exactly where the database will be updated). I'll appreciate any pointers or perhaps even an online example of something similar.
Alternatively I suppose you could pass an "id" parameter on with the commandLink that somehow gets read in the request and the appropriate row is removed accordingly. This solution seems cumbersome however.Yes, your instincts are correct there. Binding the data model to a backing bean to get the UIData instance for the table. Then use UIData.getRowData() to get the object corresponding to the row containing the link/button. Then execute your business logic to delete the row from the database. Then you need to ensure the data model is updated to reflect the new state of the database.

Similar Messages

  • Deleting single row from Special Price for Business Partners

    Hi Experts,
    How would I go about about deleting a single row from Special Prices for Business Partners across all BPs when for most of my BPs this is the only special price they have.  I have tried using Copy Discounts function but once you are down to 0 rows the record has effectively gone from the table so there is nothing to copy. 
    Hopefully I won't have to go thorugh 5000 records and delete each one idividually.
    Thanks
    Jon

    Hi Jon,
    You may try a tool called B1TCH:
    /people/community.user/blog/2007/08/19/get-your-kicks-with-di-commander
    Thanks,
    Gordon

  • Delete single row from DBTAB

    Hi Experts,
    I want to delete a single row from DBTAB ( KLAH )
    WHERE KLAHKLART = '2'  and  KLAHCLINT = '241'.
    Please advice
    Karthik

    Hi ,
    Try this code  To delete single record from DB table- -
    DATA : t_klah LIKE TABLE OF klah,
           fs_klah LIKE klah.
    SELECT * FROM klah INTO TABLE t_klah
                   WHERE klart = '2' AND
                         clint = '241'.
    LOOP AT t_klah INTO fs_klah.
      DELETE klah FROM fs_klah .
      EXIT.
    ENDLOOP.
    Regards
    Pinaki

  • How to delete a single data from table using control file

    I want delete a single row data from table using sql loder control file
    Edited by: 977940 on Dec 19, 2012 9:00 PM

    977940 wrote:
    I want delete a single row data from table using sql loder control file
    Edited by: 977940 on Dec 19, 2012 9:00 PMWhy?
    And how do you imagine this happening with sqlloader?
    The entire purpose of sqlloader is to load data (hence, the name sql*loader*) into a table from an external source. If you want to delete rows from a table, you use the sql DELETE statement.
    What is the business problem you are trying to solve?

  • Retrieve a single row from Oracle function

    Hi!
    I have an Oracle function created as follow:
    CREATE OR REPLACE FUNCTION user_data(userId IN users.user_id%TYPE)
    RETURN users%ROWTYPE AS
    userData users%ROWTYPE;
    BEGIN
    SELECT * INTO userData
    FROM users
    WHERE user_id = userId;
    RETURN userData;
    END user_data;
    This function returns a single row from 'users' table.
    I tried to retrieve that single row by mean of:
    CallableStatement statement = connection
    prepareCall("{ call ? := get_data(?) }");
    statement.*registerOutParameter(1, OracleTypes.OTHER)*;
    statement.setInt(2, 103);
    statement.execute();
    ResultSet rs = (ResultSet) statement.getObject(1);*
    String value = rs.getString(2);
    System.out.println(value);
    But this code doesn't work.
    I tried other OracleTypes, also. (I don't know what OracleType I receive when the Oracle function return a ROWTYPE.)
    Can somebody tell me how to retrieve that single row?
    What is the type of out parameter (registerOutParameter()) when the Oracle function return a ROWTYPE?
    Notes: No cursor can be added. No database change is allowed.
    Thank you in advance.
    [Adrián E. Córdoba]
    Edited by: aecordoba on Mar 18, 2011 3:58 PM

    aecordoba wrote:
    I beg your pardon for my bad English. (It isn't my original language.)
    It's not a language problem. It's that you didn't provide any details about what went wrong.
    That just is my problem:
    I know the retrieved result is not a result set: It's a single row.Doesn't matter if it's a single row. You have a ResultSet object. You have to call ResultSet's next() method to get to the first row, even if it's the only row.
    1- Which is the Oracle type I receive in Java when the Oracle function returns a ROWTYPE?I don't know.
    2- How can I get each column value when I receive a single row in Java?The same way as when there are multiple rows: For each row, call ResultSet.next() to advance to the next row, then call the appropriate ResultSet.getXxx() methods to get each column's value. Again: If you have a ResultSet, you must call next() to get to the first row, even if there is only one row. "First row out of 1 total row" is no different than "first row out of 100 total rows."
    EDIT: Okay, I didn't notice before that you're using a CallableStatement with "out" parameters. I've never used one of those before, so I'm not familiar with the details. I really don't know if casting to a ResultSet is appropriate here. Do you actually have documentation that says you can do that, or are you just guessing and trying to find something that works.
    Edited by: jverd on Mar 18, 2011 11:26 AM

  • How to delete a single request from DSO in BI 7.0

    Dear Experts,
    Could you please tell me how to delete a single request from DSO?
    I mean, in DSO if we delete one request it also delete the requests which are above it. But i don't to delete the above it.
    Please suggest me this issue.
    Regards,
    Prathap

    IN DSO--its a very basic thing....
    ACTIVE TABLE and CHANGELOG tables are overwritten after activation of each request.
    So ,each new request has a realationsip with the older request.
    So in the cases:
    1.If you activate the older request it will delete the new one ,because changelog entries have been written from the data of new request on the basis of the older one.
    e.g older request  entries:
    a x 1
    new request
    a x 2
    change log
    a x 1
    a x -1
    a x 2
    so its quite obvious you can't have  a x 2 directly (because in the infocube you will be sending wrong entries by deleting the just the older request and loadning new request).
    2.If you have activate new and old request toghterh then also system will not allow you to delete the newer request alone and you will have to delete both the requests.
    I guess already someone proposed correct solution to you ...thats selective deletion...but rahter than doing selective deletion there is a better way if you want to cancel out a particular request:
    thats request reverst posting
    IN the process monitor of any particular request you can find out the option for request reverse posting..Its good for individual request cancellation(keyfig values will become 0 for that particular request)
    regards,
    rk

  • How can I delete a single song from my iPad?

    How can I delete a single song from my iPad?

    Hi lizdance40,
    The first part of your answer worked great, thanks for that!  However, since doing that, there are still songs on the iPad that I want to delete. I place my finger on the song, swipe to the left....and nothing. No red "delete" appears at the right. That used to work on my full size iPad, but not on this mini. I just purchased it last Friday...maybe it's defective?
    Thanks again,
    Sirsheila

  • Deleting a single field from existing Layout - Update

    Hi,
    We need to amend our custom integrator's layout by removing a field from the layout.
    However, in Desktop Integration - "Define Layout" - we do not have any option to delete a field (options are - Move Up/down, Read only, width,Frozen pane)
    (Making width - 0 is not solving the purpose since only the field is not visible in layout but mappings remain as is)
    Is there any option to remove a single field from integrator layout?
    Thanks much in advance,
    Rgds,
    Sumanth

    Duplicate post - Deleting a single field from existing Layout - Update
    Srini

  • Deleting a single field from existing WebADI Layout (Update)

    Hi,
    We need to amend our custom WebADI integrator's layout by removing a field from the layout.
    However, in Desktop Integration - "Define Layout" - we do not have any option to delete a field (options are - Move Up/down, Read only, width,Frozen pane)
    (Making width - 0 is not solving the purpose since only the field is not visible in layout but mappings remain as is)
    Is there any option to remove a single field from integrator layout?
    Thanks much in advance,
    Rgds,
    Sumanth

    Duplicate post - Deleting a single field from existing Layout - Update
    Srini

  • Deleting a single item from the trash.

    Hello
    Is there a way to delete a single item from the trash, while leaving all other items in the trash?

    I don't believe so and I'm not sure why you would want to.
    Items should not be placed in the Trash unless you intend to delete the items. The Trash is not designed for and should not be used as a temporary storage location.

  • How to update single row of ms access database

    Hi All,
    can somebody tell me how can i edit/update a single row of ms access database?
    let say i want to edit the first row of the figure in the left. What i want is when i click in the row, it will pop up a window where i can edit the fields content. or may be is it possible to add a column with "edit" text which link to the appropriate row. so when i click the "edit" it will open the edit window.
    Thank you

    If you use a multi-column listbox indicator there is a "double-click" event that you can capture with an event structure. The event, when fired, returns the row that the user double-clicked. Use that parameter to fetch/modify the data as needed. Remember that to update the data in the database the table containing the data must have a primary key - or at lease something you can use to uniquely identify the rows.
    Remember that in a database, there is no such thing as "the first row"; you have to explicitly identify which row you wish to modify.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • I want to delete a single contact from history.

    Hi!! I want to delete a single contact from history. I have read that few users have asked similar questions in the past as well and also I have found some of them answering or rather questioning why one will like to delete a single log from the history. ???
    The answer is simple. For me, I may not want my friends/parents or any other know whom I was talking with. This feature is very much there in Nokia and it is very usefull as well.
    So in case, any body find the solution, please reply.

    In the present iOS, it's all or nothing. You can suggest Apple add the ability to edit the call history log here:
    http://www.apple.com/feedback/iphone.html

  • Single row from this query without create a group by

    Can I have a single row from this query without create a group by on tipo (TIPO can have only 2 value (A,D)
    SELECT
    CASE TIPO
    WHEN 'D' THEN SUM(IMPORTO) ELSE 0 END DIMPORTO,
    CASE TIPO
    WHEN 'A' THEN SUM(IMPORTO) ELSE 0 END AIMPORTO
    FROM MGIORNALE
    WHERE K_CONTO = '100001' --CONTO
    AND DECODE(T_MOVIM,'MRAP',TO_DATE('31/12/'||to_char(a_competenza),'DD/MM/YYYY'),DATA_RG)
    -- BETWEEN DATAA AND DATAB
    BETWEEN '01/01/2006' AND '31/12/2006'
    --GROUP BY TIPO
    --AND TIPO = COL_conto
    Thanks in advance

    Is like this?
    sum (CASE TIPO
    WHEN 'D' THEN IMPORTO ELSE 0 END) DIMPORTO,

  • Single row from one-to-many

    I am having trouble with a query, I need a single row from a 1-to-many relationship that is prioritized by certain ID's.
    Department Table - dept_id,dept_name
    Employee Table - emp_id, emp_name
    D-E-Lookup Table - dept_id,emp_id
    Employee ID priority are 5,8,9,21,33,78
    I need each department name with the associated employee name.
    There should be only one row per department.
    If that department does not have empID 5, than 8, if not 8 then 9, if not 9 than 21, etc
    Any help would be greatly appreciated.

    How about this:
    WITH departments AS
        ( SELECT ROWNUM AS deptno, COLUMN_VALUE AS dname
          FROM   TABLE(sys.dbms_debug_vc2coll('Sales','IT','Research')) )
       , employees AS
        ( SELECT ROWNUM AS empno, COLUMN_VALUE AS ename
          FROM   TABLE(sys.dbms_debug_vc2coll('Bennett','Parkman','Nakamura')) )
       , department_assignments AS
         ( SELECT 1 AS deptno, 1 AS empno, 5 AS priority FROM dual UNION ALL
           SELECT 1 AS deptno, 2 AS empno, 8 AS priority FROM dual UNION ALL
           SELECT 1 AS deptno, 3 AS empno, 9 AS priority FROM dual UNION ALL
           SELECT 2 AS deptno, 2 AS empno, 8 AS priority FROM dual UNION ALL
           SELECT 2 AS deptno, 3 AS empno, 9 AS priority FROM dual UNION ALL
           SELECT 3 AS deptno, 1 AS empno, 9 AS priority FROM dual UNION ALL
           SELECT 3 AS deptno, 3 AS empno, 21 AS priority FROM dual )
    SELECT dname, ename, priority
    FROM   ( SELECT d.dname
                  , e.ename
                  , dp.priority
                  , DENSE_RANK() OVER (PARTITION BY d.deptno ORDER BY dp.priority) AS ranking
             FROM   departments d
                    LEFT JOIN department_assignments dp ON dp.deptno = d.deptno
                    LEFT JOIN employees e ON e.empno = dp.empno )
    WHERE ranking = 1;
    DNAME         ENAME             PRIORITY
    Sales         Bennett                  5
    IT            Parkman                  8
    Research      Bennett                  9
    3 rows selectedThe <tt>WITH</tt> clause is just to define test data inline rather than creating tables, in case that's not clear.

  • Select a single row from a billion row table

    This is a fictitious scenario, how would you write a select statement on a table with a billion rows. It never returns anything,right? Somebody was suggesting a stored procedure.
    As an example : Assuming a Table with columns      Account(int), TransDate(DateTime), TransNum(int) and few other columns. I need a transaction that happened on 03-05-2014 8:15PM. Clustered index on Account. Non- clustered on TransDate.
    I was suggested to create a stored procedure, inside the SP you have 3 parameters: min_date, max_date, avg= min_date+max_date/2. You create a loop and feed the avg value to the max_date or min_date depending on where the row is. This is a suggestion
    that I am not clear my-self but wanted to see if you guys can help me develop this idea.
    Also please suggest how you would do it in your world. You guys could have much better ideas probably much simpler one's. Thanks in advance.
    svk

    I basically just need transaction for one particular datetime. Not any span. One of our senior developers suggested that a simple select statement takes for ever to return a single row from a billion rows and suggested a vague idea as above. 
    Either there is a suitable index on the column, and the SELECT will be fast.
    Or there is no index on the column, and in that case it will take quite some time to find the row. The only reason to loop is that you don't want to take out a table lock, but in that case you would do something like looping one account at a time. Looping
    over different time values will only mean that you will scan the table multiple times.
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for