How to update and delete records in a text file?

Hi,
I had a text file in which contains records line by line with ',' as delimiter as I use stringtokenizer and vector to read the data.
The format in the text file likes: Name, Sex, Age.
I want to add 2 functions:
(1) update the record by name, sex or age;
(2) delete the whole line of record;
Do I need to open a temp text file to do it?
And, what is the algorithm can be suggested?
For both of them, I want to firstly read the total line numbers. Then, the line number + Name, Sex, Age will be displayed on the console window. User can choose which line of record to update or delete.
Or, user can search name in order to do that.
But, what is the backend algorithm to handle it? If I have 10 lines of record, I want to delete 7th line, the 7th line of the text file will be blanked. How can I move 8th, 9th and 10th lines of records up by one line in order to fill the blank line?
Do I need to copy the first 6 lines to a temp text file and copy the last 3 lines of records to the same temp file first? and then copy all the content of that temp file back to the original text file? If so, how can I copy the same format of the original file (with '\n') to the temp file? I need the same data structure likes Name, Sex, Age.
However, when I add records, I need to append the text in the original text file, not override it's current content.
Any advice?
Thanks
gogo

If your file is not designed to be amazingly large, then you don't need to use a temporary file -- you can just read the data into memory and manipulate it there. (Like, into a Document object or something.)
But if you are dealing with really large files, you might want to consider using a database back end instead of a text file, which is a completely different approach I know but... well, that's why databases were invented.

Similar Messages

  • How to update or delete records in a Complex View in Forms?

    Hi,
    I have a requirement to create a Form by using Complex View. Insertion is possible but updation and deletion is not working properly . I got FRM-40501 Error. I need How to update or delete records in a Complex View in Forms?
    Thanks & Regards,
    Hari Babu

    Depending on how complex your view is, forms is not able to determine how to appropiately lock a record, when you try to update or delete a record.
    One approach to using complex views in forms:
    1. Set the Key-mode of the block to "Non-Updateable"
    2. Mark the column which can be used to build the WHERE-condition to uniquely identify a record with "Primary Key" = "Yes"
    3. For doing INSERT, UPDATE and DELETE, create an INSTEAD-OF-trigger on the view.
    4. Create your own ON-LOCK-trigger in forms which does the locking of the records to update.

  • How to update and delete using rest services in SharePoint 2013..

    I am looking to create,update and delete data in SharePoint list where i am using below code for creating data..I should be performing three operations on single button click how can i achieve this.Below is the code i am using for creating data to list and
    displaying in CEWP.
    <html>
    <head>
    <style type="text/css">
    #mytable{
    border : 1px solid;
    </style>
    <script type="text/javascript" src="https://sharepointapp28.sharepoint.com/sites/Dev2013/SiteAssets/Scripts/jquery-1.11.1.min.js" ></script>
    <script type="text/javascript">
    var ListName;
    var webUrl;
    $(document).ready(function(){
     SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);//Doubt
    function sharePointReady() {
    webUrl = _spPageContextInfo.siteAbsoluteUrl;
    ListName = "test"; 
    $('#btnSub').click(function () {
    updateItem();
    function updateItem() {
    var name = $('#txtName').val();
    var Desc = $('#txtDesc').val();
    var city = $('#txtCity').val();
        var itemType = GetItemTypeForListName(ListName);
        var item;
            item = {
                '__metadata': { "type": itemType },
                'Name': name,
                'Description': Desc,
                'City': city
        var xmethod = 'POST';
        jQuery.ajax({
            url: webUrl + "/_api/web/lists/getbytitle('" + ListName + "')/items",
            type: "POST",
            data: JSON.stringify(item),
            contentType: "application/json;odata=verbose",
            headers: {
                "Accept": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            success: onUpdateMSOPProcessSuccess,
            error: onUpdateMSOPProcesFail
        function onUpdateMSOPProcessSuccess(data) {
    alert('successfully updated to MyList!!!')
        function onUpdateMSOPProcesFail(data) {
            alert(data.d.err);
    function GetItemTypeForListName(name) {
        return "SP.Data." + name + "ListItem";
    </script>
    </head>
    <body>
    <table style="width:500px" id="mytable">
    <tr><td colspan="3">&nbsp;</td></tr>
    <tr><th colspan="3">Rest API</th></tr>
    <tr><td colspan="3">&nbsp;</td></tr>
    <tr><th>Name</th> <td> : </td> <td> <input type="text" id="txtName" /> </td></tr>
    <tr><th>Description</th> <td> : </td> <td> <input type="text" id="txtDesc" /> </td></tr>
    <tr><th>City</th> <td> : </td> <td> <input type="text" id="txtCity" /> </td></tr>
    <tr><td colspan="3">&nbsp;</td></tr>
    <tr><th></th><td colspan="2" align="left"><input type="button" value="submit" id="btnSub" /></th></tr>
    <tr><td colspan="3">&nbsp;</td></tr>
    </table>
    </body>
    </html>

    Hello,
    With one button you want to perform 3(Create, Update and Delete) operation
    To create:
    First check whether the data exist with full combination of Name,Desc and City.
    If not exist you can execute the create function.
    If exist, get confirmation to delete the item by pop up. Using item ID you can perform Delete operation
    To Update:
    How you want to update the item, by keeping unique value or combination of columns?
    based on that you can perform the update operation.
    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

  • Updating and deleting records in access DB

    i'm trying to make multiple updates and deletes in a access DB and it doesn't work.
    my program executes lot's of updates and delete statements when saving, but I only commit in the end when I know all the statements finished ok.
    I can't make it a batch update since I need to retrieve the auto-number that access issues me on some of my tables.
    I know it's kinda fuzzy, but my program is SO big already, and I can't really put the code in here - it wouldn't do much good.
    what I will do is write what my log shows (i issue a log output whenever there's a executeQuery/Update and before commit/rollback
    DBG : 29/04/03 : UPDATE CASES_T SET CASE_office_case_id = 1 ,CASE_year = 2 ,CASE_total_debt = 10009 ,CASE_is_limited = true ,CASE_monthly_payment = 400 ,CASE_hotzlap_case_id = ' - - - ' ,CASE_status = 26 WHERE CASE_tech_id = 5
    DBG : 29/04/03 : SELECT count(*) from CASES_OWEES_T where CAOW_Tech_Id = 23
    DBG : 29/04/03 : UPDATE CASES_OWEES_T SET CAOW_case_tech_id = 5 ,CAOW_id_number = '046259990' ,CAOW_first_name = '���' ,CAOW_last_name = '������' ,CAOW_work_place = 'jjjjjjjjjjjjj' ,CAOW_address = '1jjjjjjjjjjjj' ,CAOW_telephone = '09-8099999' ,CAOW_pelephone = '000-000000' ,CAOW_hotzlap_case_id = ' - - - ' ,CAOW_is_valid_address = false WHERE CAOW_TECH_ID = 23
    DBG : 29/04/03 : SELECT count(*) from CASES_OWEES_T where CAOW_Tech_Id = 24
    DBG : 29/04/03 : UPDATE CASES_OWEES_T SET CAOW_case_tech_id = 5 ,CAOW_id_number = ' ' ,CAOW_first_name = '�����' ,CAOW_last_name = '���' ,CAOW_work_place = '����' ,CAOW_address = '��?' ,CAOW_telephone = ' - ' ,CAOW_pelephone = ' - ' ,CAOW_hotzlap_case_id = ' - - - ' ,CAOW_is_valid_address = true WHERE CAOW_TECH_ID = 24
    DBG : 29/04/03 : SELECT count(*) from CASES_INNER_CASES_T where CICA_Tech_Id = 10
    DBG : 29/04/03 : UPDATE CASES_INNER_CASES_T SET CICA_case_tech_id = 5 ,CICA_debt = 5000897 ,CICA_winner_name = '���' ,CICA_lawyer_tech_id = '6' ,CICA_hotzlap_case_id= '02-22122-22-2' WHERE CICA_tech_id= 10
    DBG : 29/04/03 : SELECT count(*) from CASES_INNER_CASES_T where CICA_Tech_Id = 11
    DBG : 29/04/03 : UPDATE CASES_INNER_CASES_T SET CICA_case_tech_id = 5 ,CICA_debt = 20008 ,CICA_winner_name = '������' ,CICA_lawyer_tech_id = '2' ,CICA_hotzlap_case_id= '02-22222-22-2' WHERE CICA_tech_id= 11
    DBG : 29/04/03 : SELECT count(*) from CASES_INNER_CASES_T where CICA_Tech_Id = 14
    DBG : 29/04/03 : UPDATE CASES_INNER_CASES_T SET CICA_case_tech_id = 5 ,CICA_debt = 129 ,CICA_winner_name = '' ,CICA_lawyer_tech_id = '4' ,CICA_hotzlap_case_id= '02-22222-22-2' WHERE CICA_tech_id= 14
    DBG : 29/04/03 : SELECT count(*) from CASES_CUSTOMER_CARDS_T where CUCA_Tech_Id = 23
    DBG : 29/04/03 : UPDATE CASES_CUSTOMER_CARDS_T SET CUCA_case_tech_id = 5 , CUCA_sum = 324 , CUCA_fee_plus_maam = -38.0 , CUCA_for_division = 285.0 , CUCA_voucher = '3222 ' , CUCA_date = '2003-04-24' , CUCA_in_or_out = true WHERE CUCA_tech_id = 23
    DBG : 29/04/03 : SELECT count(*) from CASES_CUSTOMER_CARDS_T where CUCA_Tech_Id = 22
    DBG : 29/04/03 : UPDATE CASES_CUSTOMER_CARDS_T SET CUCA_case_tech_id = 5 , CUCA_sum = 324 , CUCA_fee_plus_maam = -38.0 , CUCA_for_division = 285.0 , CUCA_voucher = '2222 ' , CUCA_date = '2003-04-23' , CUCA_in_or_out = true WHERE CUCA_tech_id = 22
    DBG : 29/04/03 : SELECT count(*) from CASES_CUSTOMER_CARDS_T where CUCA_Tech_Id = 21
    DBG : 29/04/03 : UPDATE CASES_CUSTOMER_CARDS_T SET CUCA_case_tech_id = 5 , CUCA_sum = 100 , CUCA_fee_plus_maam = -11.0 , CUCA_for_division = 0.0 , CUCA_voucher = '2222 ' , CUCA_date = '2003-04-23' , CUCA_in_or_out = true WHERE CUCA_tech_id = 21
    DBG : 29/04/03 : SELECT count(*) from CASES_CUSTOMER_CARDS_T where CUCA_Tech_Id = 20
    DBG : 29/04/03 : UPDATE CASES_CUSTOMER_CARDS_T SET CUCA_case_tech_id = 5 , CUCA_sum = 1000 , CUCA_fee_plus_maam = -118.0 , CUCA_for_division = 882.0 , CUCA_voucher = '1111 ' , CUCA_date = '2003-04-23' , CUCA_in_or_out = true WHERE CUCA_tech_id = 20
    DBG : 29/04/03 : SELECT count(*) from CASES_INVESTIGATIONS_T where CAIN_Tech_Id = 16
    DBG : 29/04/03 : UPDATE CASES_INVESTIGATIONS_T SET CAIN_case_tech_id = 5 ,CAIN_text = '' ,CAIN_was_declared_limited = false ,CAIN_date = '2003-03-01' ,CAIN_rulling_effective_date = '2003-02-01' ,CAIN_payment_amount = 400 WHERE CAIN_TECH_ID = 16
    DBG : 29/04/03 : SELECT count(*) from CASES_INVESTIGATIONS_T where CAIN_Tech_Id = 12
    DBG : 29/04/03 : UPDATE CASES_INVESTIGATIONS_T SET CAIN_case_tech_id = 5 ,CAIN_text = '' ,CAIN_was_declared_limited = true ,CAIN_date = '1970-01-01' ,CAIN_rulling_effective_date = '1905-03-06' ,CAIN_payment_amount = 90 WHERE CAIN_TECH_ID = 12
    DBG : 29/04/03 : SELECT count(*) from CASES_INVESTIGATIONS_T where CAIN_Tech_Id = 10
    DBG : 29/04/03 : UPDATE CASES_INVESTIGATIONS_T SET CAIN_case_tech_id = 5 ,CAIN_text = '' ,CAIN_was_declared_limited = false ,CAIN_date = '1970-01-01' ,CAIN_rulling_effective_date = '1990-01-30' ,CAIN_payment_amount = 89 WHERE CAIN_TECH_ID = 10
    DBG : 29/04/03 : DELETE FROM CASES_INVESTIGATIONS_T where CAIN_tech_id = 9
    DBG : 29/04/03 : DELETE FROM CASES_INVESTIGATIONS_T where CAIN_tech_id = 9
    DBG : 29/04/03 : DELETE FROM CASES_INVESTIGATIONS_T where CAIN_tech_id = 14
    DBG : 29/04/03 : DELETE FROM CASES_INVESTIGATIONS_T where CAIN_tech_id = 14
    DBG : 29/04/03 : DELETE FROM CASES_INVESTIGATIONS_T where CAIN_tech_id = 13
    DBG : 29/04/03 : DELETE FROM CASES_INVESTIGATIONS_T where CAIN_tech_id = 13
    DBG : 29/04/03 : DELETE FROM CASES_INVESTIGATIONS_T where CAIN_tech_id = 11
    DBG : 29/04/03 : DELETE FROM CASES_INVESTIGATIONS_T where CAIN_tech_id = 11
    DBG : 29/04/03 : SELECT count(*) from CASES_PAYMENTS_T where CAPY_Tech_Id = 71
    DBG : 29/04/03 : UPDATE CASES_PAYMENTS_T SET CAPY_case_tech_id = 5 ,CAPY_sum = 400 ,CAPY_exception_text = '' ,CAPY_is_exception = true ,CAPY_voucher = '' ,CAPY_date = '2003-04-01' ,CAPY_is_paid_in_hotzlap = false WHERE CAPY_TECH_ID = 71
    DBG : 29/04/03 : SELECT count(*) from CASES_PAYMENTS_T where CAPY_Tech_Id = 70
    DBG : 29/04/03 : UPDATE CASES_PAYMENTS_T SET CAPY_case_tech_id = 5 ,CAPY_sum = 400 ,CAPY_exception_text = '' ,CAPY_is_exception = true ,CAPY_voucher = '' ,CAPY_date = '2003-03-01' ,CAPY_is_paid_in_hotzlap = false WHERE CAPY_TECH_ID = 70
    DBG : 29/04/03 : SELECT count(*) from CASES_PAYMENTS_T where CAPY_Tech_Id = 69
    DBG : 29/04/03 : UPDATE CASES_PAYMENTS_T SET CAPY_case_tech_id = 5 ,CAPY_sum = 400 ,CAPY_exception_text = '' ,CAPY_is_exception = true ,CAPY_voucher = '' ,CAPY_date = '2003-03-01' ,CAPY_is_paid_in_hotzlap = false WHERE CAPY_TECH_ID = 69
    DEV : 29/04/03 : commit

    sure - I don't get any exception. the data just
    doesn't show in the DB. (no updating/deletion of
    records)
    as I wrote before - when the the programm commits the
    changes and does the next select command it seems as
    if the data was changed/deleted but if I check the DB
    with access or if I restart the prgoram then I see
    that the data didn't change.
    Access/jdbc-odbc has a problem where modifications are not 'commited' when the statement completes. Instead one must do one of the following:
    1. Explicit commit.
    2. Simple select after statement.
    3. Close the connection.
    Presumably you are doing 1.
    Since other than this it does work, it suggests one of the following.
    1. Something is wrong with your environment. For instance you are looking at the wrong database. Or not refreshing. Or something else like that.
    2. You are using something besides a simple connection - like opening it with 'scroll insensitive'.
    3. The complexity is causing it to lose an error message. This can be tested by doing each statement individually and verify that none produce an error.
    4. Maybe you found a bug. You can turn on ODBC tracing via the applet panel and see if digging through all of the detail provides any clues (you can also do this with 3 above.)

  • Unable to update and delete record in table

    Hello All,
    Kindly help me regarding the below mentioned issue plz
    When I want to update or delete record in table from form developed in 6i give no error message but no action and when I run same form on other system updation and deletion are successfully done.
    Any suggestion

    Hello
    More explanation is as under:
    1. I am working on only one table say A
    2. Wants to update only one row of Table A at one time in single user envoirment.
    3. My form is successfully update some rows as well but not on all rows on one PC while same form able to update all rows on other PC.
    4. I drop the table and re-create the table again but problem persist.
    Any advice plz.

  • Creating Update and deleting Records Forms

    Hi Guys
    Hopefully some one can help me with this, I am using php and
    mysql, I already have a page that shows all the records of
    customers details, which I can navigate through the pages of
    records.
    I have created a update page, using the update wizard, which
    works but only shows the first record. I have added a repeat region
    and page navigation which allows me to choose individual records
    but wont update those records.
    I also took a look at a tutorial video that had you adding an
    extra column and add the word update to add a hyperlink that took
    you to the update form with that particular record for updating,
    the video was using cold fusion the link was update page address
    then this ?ID=#ID#, I tried different versions of this with no
    success.
    I also tried to alter the record set and added a filter using
    Member_ID and = paramater URL, this made my cusomter detail page
    stop working.
    can some one help please
    Cheers
    Mark

    burkeslaw wrote:
    > Is it that I have to create the update form manually and
    then select it and
    > add the update form behaviour? Is there an Go to
    Detailed Page server behaviour
    > for php, or is this just for ASP technology.
    I'm not familiar with the ASP server behaviors, but there is
    a Master
    Detail Page Set for PHP (it's on the Insert > Data Objects
    menu).
    Creating an update page is very easy.
    1. Create a page that lists all records in the database.
    2. Alongside each record, create a link to the update page.
    3. When creating the link, click the Parameters button inside
    the Select
    File dialog box.
    4. In the Name field of the Parameters dialog box, type the
    name of the
    primary key (ID).
    5. Click the lightning bolt icon to the right of the Value
    field, and
    select the primary key from the recordset.
    6. Click OK twice to close both dialog boxes.
    7. Save the page and test it in a browser. When you mouse
    over each
    link, it should display a URL that looks something like this:
    update.php?id=3. The name/value pair after the question mark
    pass the
    details of the record as a URL parameter to the update page.
    8. In the update page, create a recordset that uses the URL
    parameter as
    a filter to select a single record depending on the value
    sent from the
    previous page.
    9. In the update page, create a hidden field to store the ID
    from the
    recordset (click the lightning bolt icon alongside the Value
    field to
    insert the dynamic data).
    10. Apply an Update Record server behavior. Make sure the
    primary key
    gets its value from the hidden field in the form.
    Alternatively, if you don't want to build your own update
    form, replace
    steps 9 and 10 by using the Record Update Form Wizard (Insert
    > Data
    Objects > Update Record > Record Update Form Wizard).
    David Powers
    Adobe Community Expert, Dreamweaver
    http://foundationphp.com

  • How to Implement basic Insert ,Update and delete Actions

    Hi all,
              i want to implement 1)INSERT 2)UPDATE 3)DELETE actions in webdynpro application means i have to add a new record to my R/3 backend and update and delete records from my database
    can anyone tell me how to do these actions
    Regards
    Padma N

    Hi Murtuza ,
                           I have 2 views in my application.In the first view i enterd some purchaseorder number and clicked serarch button.The items regarding that purchaseorder gets populated in the table which is in second view.All the data is in R/3 backend system.
    the code i used to get the details of that particular purchaseorder is
    try {
    wdcontext.currentZ_Matrls_For_Inputlement().modelObiect.execte();
    catch(RFCException e){
    /* Catch the Exception Here */
    Here now i want to delete one record of that particular purchaseorder from the database.So Wat should be the code to delete record from R/3 Model
    Regards
    Padma N

  • How to perform insert, update and delete in a table component

    hi all,
    i am using a table component in my page. I want to retreive data from multiple tables as well as perform insertion, updation and deletion operation.The changes should be affected in the corresponding tables. can anyone provide a solution for my problem.
    Thanks in advance
    regards,
    prasant

    There is a great tutorial for insert, update and delete records in a table.
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/inserts_updates_deletes.html
    Hope it helps.
    Thanks,
    Moumita

  • How to update and insert the records without using Table_comparison and Map_operation?

    How to update and insert the records without using Table_comparison and Map_operation?

    Use either join or MERGE see this Inserting, Updating, and Deleting Data by Using MERGE

  • I am making an iMovie trailer on my iPad 3(updated) and I recorded a few clips on my iPad Camera but they are not being detected on the iMovie Videos section. How can I make them show up?

    I am making an iMovie Trailer on my iPad 3 (updated) and I recorded a few clips using my iPad Camera but they are not being detected on the iMovie Videos scetion. How can I make them appear so I can use them in my trailer?

    Hi Stuck-in-NY,
    If you are looking to transfer your purchases to your computer, you may find the following article helpful:
    Apple Support: Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/HT2519
    Regards,
    - Brenden

  • SUN TEAM: Bugs in update and delete a record with long query

    Creator Team,
    In my opinio there is a bug issue with update and delete a record with a complex sql query. I�m using oracleXE and ojdbc14.ar with tomcat
    In just two page I�m receving the following msg (I have 12 pages doing the same thing with less complex queries)
    * Number of conflicts while synchronizing: 1 SyncResolver.DELETE_ROW_CONFLICT row 2 won't delete as values in database have changed: 2006-11-29
    * Cannot commit changes: Number of conflicts while synchronizing: 1 SyncResolver.UPDATE_ROW_CONFLICT row 0 values changed in database
    when i tried to delete or commit the updated changes in the register...
    The interesting is that this code function with jdbc of jsc...
    My query is bellow:
    SELECT ALL PATRIMONIO.TB_BEM.INCODIGOBEM,
    PATRIMONIO.TB_BEM.VATOMBAMENTO,
    PATRIMONIO.TB_BEM.VAMATERIAL,
    PATRIMONIO.TB_BEM.INCODIGOSETOR,
    PATRIMONIO.TB_SETOR.VANOME AS NOMESETOR,
    PATRIMONIO.TB_BEM.INCODIGOFORNECEDOR,
    PATRIMONIO.TB_FORNECEDOR.VANOME AS NOMEFORNECEDOR,
    PATRIMONIO.TB_BEM.DACHEGADA ,
    PATRIMONIO.TB_BEM.DASAIDAPREVISTA,
    PATRIMONIO.TB_BEM.DASAIDAEFETIVA,
    PATRIMONIO.TB_BEM.VAMARCA,
    PATRIMONIO.TB_BEM.VAMODELO,
    PATRIMONIO.TB_BEM.VADESBAIXABEM,
    PATRIMONIO.TB_BEM.INCODIGOTIPOAQUISICAO,
    PATRIMONIO.TB_TIPOAQUISICAO.VANOME AS NOMETIPOAQUISICAO
    FROM PATRIMONIO.TB_BEM , PATRIMONIO.TB_TIPOAQUISICAO, PATRIMONIO.TB_SETOR, PATRIMONIO.TB_FORNECEDOR
    WHERE PATRIMONIO.TB_BEM.INCODIGOTIPOAQUISICAO = PATRIMONIO.TB_TIPOAQUISICAO.INCODIGOTIPOAQUISICAO
    AND PATRIMONIO.TB_BEM.INCODIGOSETOR = PATRIMONIO.TB_SETOR.INCODIGOSETOR
    AND PATRIMONIO.TB_BEM.INCODIGOFORNECEDOR = PATRIMONIO.TB_FORNECEDOR.INCODIGOFORNECEDOR
    AND PATRIMONIO.TB_BEM.INCODIGOBEM LIKE ?
    AND PATRIMONIO.TB_BEM.VATOMBAMENTO LIKE ?
    AND PATRIMONIO.TB_BEM.VAMATERIAL LIKE ?
    AND PATRIMONIO.TB_SETOR.VANOME LIKE ?
    AND PATRIMONIO.TB_FORNECEDOR.VANOME LIKE ?
    ORDER BY PATRIMONIO.TB_BEM.VATOMBAMENTO ASC
    Why this problem is happing? Did you had some solution for that? Is the problem because the query is too long?!
    please help me!
    Gustavo Callou

    Hello people,
    I�m doing this to try to solution that bug:
    This code is working fine... but I do not understand why I�m receiving the nullpointer exception!??!!?
    // create a new rowset
    CachedRowSetXImpl pkRowSet = new CachedRowSetXImpl();
    try {
    RowKey rk = tableRowGroup1.getRowKey();
    if (rk != null) {
    // set the rowset to use the Patrimonio database
    pkRowSet.setDataSourceName("java:comp/env/jdbc/Patrimonio");
    String query = "DELETE FROM TB_BEM WHERE INCODIGOBEM = "+tb_bemDataProvider.getValue("INCODIGOBEM", rk).toString();
    pkRowSet.setCommand(query);
    pkRowSet.setTableName("TB_BEM");
    // execute the rowset -- which will contain a single row and single column
    pkRowSet.execute();
    pkRowSet.next();
    info("Apagado");
    } catch (Exception ex) {
    log("ErrorDescription", ex);
    error(getApplicationBean1().trateException(ex.getMessage()));
    } finally {
    pkRowSet.close();
    Please someone help me!!!
    Gustavo Callou

  • Update and delete a record

    Hi all
    I have a requirement in oracle forms 6i
    I have a data block which is tabular
    there are 5 columns
    1 column is display only and other 4 are normal text fields where we can insert update and delete those records
    My requirement is when a user updates a record an alert must fire and the alert should ask whether the user wants to update that particular record
    if the user presses yes then the record should be updated else the record should show as it was previously shown
    Similarly in case of delete an alert should fire where it should be asked for confirmation if the user presses yes then the record should be deleted from the data base
    else the record should be again visible on the form as earlier
    also my 3rd requirement is that
    i have a item field which is normal text and the display only field is the description
    when entering a new record when i enter the item field and press tab or navigate out of the item field then the description of the item should be pouplated into the decsription read only field
    Please help me in the above 3 cases
    I am new to forms
    I am using a friends ID which has many posts
    Thanks in advance

    1)
    your first requirement i'd do in the PRE-UPDATE trigger of the block:
    DECLARE
        v_alert_button NUMBER;
    BEGIN
        v_alert_button := SHOW_ALERT('your_alert'); -- "Do you want to update?"
        IF v_alert_button = ALERT_BUTTON1 -- assuming "No"
        THEN
            -- reset value:
            :YOUR_BLOCK.YOUR_ITEM1 := GET_ITEM_PROPERTY('YOUR_BLOCK.YOUR_ITEM1', DATABASE_VALUE);
            -- optionally set item to valid if you don't want validations to fire:
            SET_ITEM_PROPERTY('YOUR_BLOCK.YOUR_ITEM1', ITEM_IS_VALID, PROPERTY_TRUE);
            -- do this for every item:
            :YOUR_BLOCK.YOUR_ITEM2 := GET_ITEM_PROPERTY('YOUR_BLOCK.YOUR_ITEM2', DATABASE_VALUE);
            -- finally reset record status:
            SET_RECORD_STATUS(:SYSTEM.CURSOR_RECORD, STATUS, QUERY_STATUS);
            -- interrupt PRE-UPATE trigger:
            RAISE FORM_TRIGGER_FAILURE;
        END IF;
    END;(not tested, please try for youself)
    2)
    raise the alert in PRE-DELETE trigger.
    3)
    you can do this within the WHEN-VALIDATE-ITEM trigger or a List-of-value (LOV) that returns the description values.

  • Insert, update and delete on updatable join views

    Hi I need to insert, update and delete data in a views. I tried the foloing example
    http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10739/views.htm#i1006232
    We have two tables:
    CREATE TABLE dept (
    deptno NUMBER(4) PRIMARY KEY,
    dname VARCHAR2(14),
    loc VARCHAR2(13));
    CREATE TABLE emp (
    empno NUMBER(4) PRIMARY KEY,
    ename VARCHAR2(10),
    job VARCHAR2(9),
    mgr NUMBER(4),
    sal NUMBER(7,2),
    comm NUMBER(7,2),
    deptno NUMBER(2),
    FOREIGN KEY (DEPTNO) REFERENCES DEPT(DEPTNO));
    and one view:
    CREATE VIEW emp_dept AS
    SELECT emp.empno, emp.ename, emp.deptno, emp.sal, dept.dname, dept.loc
    FROM emp, dept
    WHERE emp.deptno = dept.deptno
    AND dept.loc IN ('DALLAS', 'NEW YORK', 'BOSTON');
    this update command works successfully
    UPDATE emp_dept
    SET sal = sal * 1.10
    WHERE deptno = 10;
    but this one fails because it attempts to modify the base dept table, and the dept table is not key preserved in the emp_dept view.:
    UPDATE emp_dept
    SET loc = 'BOSTON'
    WHERE ename = 'SMITH';
    I tried to create the view with "WITH CHECK OPTION" clause but whith no success :(
    My question is: how can I do this with a simple across this view. I rather not use Instead Of Trigger because it take a lot of PL/SQL code :(
    thanks in advance
    Operator

    UPDATE emp_dept
    SET loc = 'BOSTON'
    WHERE ename = 'SMITH';But that doesn't make sense. You cannot just LOC for SMITH, because LOC is not an attribute of EMP. If you change the LOC in the view then you must change it for all employees in DEPT 30 (or whatever).
    The key preserved thing is merely about maintaining your data integrity.
    I rather not use Instead Of Trigger because it take a lot of PL/SQL code :(The problem is, your business rule is not clear. Are you wanting to change the LOC for the DEPT record which is the DEPTNO to which SMITH belongs? Or are you wanting to change SMITH's DEPTNO to be the one for the BOSTON office?
    Cheers, APC

  • Insert, update and delete trigger over multiple Database Links

    Hello guys,
    first of all I'll explain my environment.
    I've got a Master DB and n Slave Databases. Insert, update and delete is only possible on the master DB (in my opinion this was the best way to avoid Data-inconsistencies due to locking problems) and should be passed to slave databases with a trigger. All Slave Databases are attached with DBLinks. And, additional to this things, I'd like to create a job that merges the Master DB into all Slave DB's every x minutes to restore consistency if any Error (eg Network crash) occurs.
    What I want to do now, is to iterate over all DB-Links in my trigger, and issue the insert/update/delete for all attached databases.
    This is possible with the command "execute immediate", but requires me to create textual strings with textually coded field values for the above mentioned commands.
    What I would like to know now, is, if there are any better ways to provide these functions. Important to me is, that all DB-Links are read dynamically from a table and that I don't have to do unnecessary string generations, and maybe affect the performance.
    I'm thankful for every Idea.
    Thank you in advance,
    best regards
    Christoph

    Well, I've been using mysql for a long time, yes, but I thought that this approach would be the best for my requirements.
    Materialized View's don't work for me, because I need real-time updates of the Slaves.
    So, sorry for asking that general, but what would be the best technology for the following problem:
    I've got n globally spread Systems. Each of it can update records in the Database. The easies way would be to provide one central DB, but that doesn't work for me, because when the WAN Connection fails, the System isn't available any longer. So I need to provide core information locally at every System (connected via LAN).
    Very important to me is, that Data remain consistent. That means, that it must not be that 2 systems update the same record on 2 different databases at the same time.
    I hope you understand what I'd need.
    Thank you very much for all your replies.
    best regards
    Christoph
    PS: I forgot to mention that the Databases won't be very large, just about 20k records, and about 10 queriees per second during peak times and there's just the need to sync 1 Table.
    Edited by: 907142 on 10.01.2012 23:14

  • Insert,update and delete commands

    hi everybody,
    how can i make a button that runs a specific insert update and delete commands
    i am using adf faces jdeveloper 11.1.1.2.0
    than you for all

    thank you guys for your interest what i need in my button click is to take some values from outputtext controls and execute an insert command according to these values what i have done is make a stored procedure and make a client interface function to my amImpl class and i have called getDBTransaction().executeCommand(command); it runs well when i didn't enter values in outputtext controls and it throws an exception when i put the values
    the exception is javax.servlet.ServletException: Unable to resolve a Validator instance using either validatorId '' or binding '#{bindings.FileName.validator}'.
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.portlet.client.adapter.adf.ADFPortletFilter.doFilter(ADFPortletFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:97)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:94)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:138)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at com.bea.content.manager.servlets.ContentServletFilter.doFilter(ContentServletFilter.java:178)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.webcenter.lifecycle.filter.LifecycleLockFilter.doFilter(LifecycleLockFilter.java:136)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:159)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:326)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3592)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: javax.faces.convert.ConverterException: Unable to resolve a Validator instance using either validatorId '' or binding '#{bindings.FileName.validator}'.
         at com.sun.faces.taglib.jsf_core.ValidatorTag$BindingValidator.validate(ValidatorTag.java:168)
         at org.apache.myfaces.trinidad.component.UIXEditableValue.validateValue(UIXEditableValue.java:345)
         at org.apache.myfaces.trinidad.component.UIXEditableValue.validate(UIXEditableValue.java:172)
         at org.apache.myfaces.trinidad.component.UIXEditableValue._executeValidate(UIXEditableValue.java:503)
         at org.apache.myfaces.trinidad.component.UIXEditableValue.processValidators(UIXEditableValue.java:270)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1024)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1009)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:816)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1024)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1009)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:816)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1024)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1009)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:816)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.access$101(ContextSwitchingComponent.java:39)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$3.run(ContextSwitchingComponent.java:122)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:309)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.processValidators(ContextSwitchingComponent.java:125)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1024)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1009)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:816)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.access$101(ContextSwitchingComponent.java:39)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$3.run(ContextSwitchingComponent.java:122)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:309)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.processValidators(ContextSwitchingComponent.java:125)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1024)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1009)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:816)
         at org.apache.myfaces.trinidad.component.UIXForm.processValidators(UIXForm.java:82)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:1024)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.validateChildren(UIXComponentBase.java:1009)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processValidators(UIXComponentBase.java:816)
         at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
         at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:700)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl$ProcessValidationsCallback.invokeContextCallback(LifecycleImpl.java:1203)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:303)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         ... 42 more
    thank you for help

Maybe you are looking for