Deleting and updating records in a database table

dear all ,
i have created a databse table to which i have to update and delete records thru my program whixh i am unable to do so plz help me.

Hi Sonu,
To delete and update the records in your database table, you can create a Function Group and all the necessary function modules for it. This will a good approach as this will separate the database interface logic and the business logic. You need to use the DELETE and UPDATE ABAP keywords to delete and update the records of the database tables. Have a look at the ABAP Keyword documentation for a complete details of the usage.
Have a look at the following link:
DELETE
http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb3aef358411d1829f0000e829fbfe/frameset.htm
UPDATE
http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb3aef358411d1829f0000e829fbfe/frameset.htm
Hope this will help.
Thanks,
Samantak.

Similar Messages

  • How can I  delete and update records using where conditions?

    I want to delete and update the coherence records with some conditions, I describe it to use SQL as follows:
    delete from "contacts" where getStreet() = "dsada";
    update contacts set getStreet() = "dddd" where getCity() = "ssss";
    Can I use the filter like query to achieve this requirement as follows:
    ValueExtractor::View vHomeStateExtractor = ChainedExtractor::create(
    ChainedExtractor::createExtractors("getHomeAddress.getState"));
    Object::View voStateName = String::create("MA");
    Set::View setResults = hCache->entrySet(
    EqualsFilter::create(vHomeStateExtractor, voStateName));
    I know I can use get and put to achieve this requirement , but it Requires a two-interaction between the client and coherence server. Does it have And another way?
    Thanks very much, and please Forgive my English is not very good.

    Hi,
    You have a couple of options for updating or deleting using a Filter.
    For deleting you can use an Entry Processor and the cache invokeAll method. Using "out of the box" Coherence you can use the ConditionalRemove entry processor. I'm a Java person so the C++ below might not be exactly right but you should get the idea.
    ValueExtractor::View vHomeStateExtractor = ChainedExtractor::create(
    ChainedExtractor::createExtractors("getHomeAddress.getState"));
    Object::View voStateName = String::create("MA");
    hCache->invokeAll(EqualsFilter::create(vHomeStateExtractor, voStateName),
    ConditionalRemove::create(AlwaysFilter.getInstance());For update you would either need to write custom Entry Processor implementations that perform the updates you require or you can use out of the box POF or Reflection ValueUpdaters that update specific fields of the entries in the cache. These valueUpdaters would be wrapped in an UpdaterProcessor so the call would be very similar to the code above.
    JK

  • Delete and update records in Stored procedures

    I AM NOW STUDYING A STORED PROCEDURE ,AND I ENCOUNTER SOME PROBLEM WITH
    UPDATE AND DELETE SOME RECORD WHICH ONE IS UPDATED OR DELETED,
    THIS IS MY CODE:
    PACKAGE table_of_array IS
    type emp_rec is record(
         empno emp.empno%type,
         ename emp.ename%type,
         sal          emp.sal%type,
         deptno emp.deptno%type
    type arr is table of emp_rec
    index by binary_integer;
    procedure get_data(a in out table_of_array.arr);
    procedure do_insert(a in out table_of_array.arr);
    procedure do_update(a in out table_of_array.arr);
    procedure do_delete(a in out table_of_array.arr);
    END;
    PACKAGE BODY table_of_array IS
    procedure get_data(a in out table_of_array.arr)
    is
    i number:=0;
    begin
         for cur in (select empno,ename,sal,deptno from emp) loop
              a(i):=cur;
              i:=i+1;     
         end loop;
    end;
    procedure do_insert(a in out table_of_array.arr)
    is
         i number:=0;
         cnt number:=a.count;
    begin
         for i in 1..cnt loop
              insert into emp(empno,ename,sal,deptno)
              values(a(i).empno,a(i).ename,a(i).sal,a(i).deptno);
         end loop;
    end;
    procedure do_update(a in out table_of_array.arr)
    is
    begin
         /* WHICH RECORD AND ITEM HAD BEEN UPDATED */
    end;
         procedure do_delete(a in out table_of_array.arr)
         is
         begin
         /* WHICH RECORD HAD BEEN DELETED */      
         end;
    END;

    when you want to update, delete or insert records with a stored procedure you have to provide a procedure that locks the records
    i'll send you an example of an update procedure and a lock procedure
    PROCEDURE p_upd_devices ( resultset IN devtab) IS
    BEGIN
    FOR i IN 1..resultset.COUNT LOOP
              IF resultset(i).zone <> resultset(i).zone_ref THEN
              p_update_zone(resultset(i).zone, resultset(i).mdv_seq);
              END IF;
         END LOOP;
    EXCEPTION WHEN OTHERS THEN
    mecoms_general.logging(0, sqlerrm, 'pck$fill_error_devices.p_upd_devices');
    END; -- p_upd_devices
    PROCEDURE p_update_zone (pi_zone in metering_devices.zne_code%type, pi_device in metering_devices.seq%type) IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
              UPDATE metering_devices
                   SET zne_code = pi_zone
                   WHERE seq = pi_device;
                   commit;
    EXCEPTION WHEN OTHERS THEN
    mecoms_general.logging(0, sqlerrm, 'pck$fill_error_devices.p_update_zone');
    END;
    PROCEDURE p_lock_devices( resultset IN OUT devtab) IS
    BEGIN
    null;
    END;

  • Access is not inserting, updating or deleting records in my database table on the server

    I am having a problem with an application I developed using Dreamweaver 8 and Access 2000 several years ago which is no longer working correctly. The problem is that Access is not inserting, updating or deleting records in my database table on the server but is reflected in changes to my Web site. I used the Dreamweaver server behaviors: insert record, update record and delete record to make the changes to my Access table on the server. My Access table on the server shows all of the records I inserted or updated in the past, but not any of the newly inserted on updated records.
    does any one have any ideas as to what my problem is?
    Jim

    No, that has nothing to do with your problem. Let's make sure I understand the symptoms.
    1) Your site is online at a remote host.
    2) You use a dynamic page in your online site to update a database record (insert, delete, or update)
    3) The update then appears correctly on your dynamic content page.
    4) You download the mdb and it appears to not have any of the upates you just made.
    Please correct any of these statements if they are wrong.
    If the above is correct, then you must be looking at a cached mdb, or the mdb you are looking at is in the wrong location. Do this: search your entire drive for copies of the mdb, including in the Windows temp directories which is likely where the cached copy is located. Delete any extra copies and download again.

  • Deleting and updating database table

    hi all,
    i have to update the database table based on my internal table(both having same structure).
    my database has 2 records having a key field 1 and 2 respectively.(2 records)
    and my internal table has records with key fields 3, 4 and 5 respectively(3 records) .
    i want to delete all data from database table first..
    then i want to insert all the three records in the database table..
    finally i want my database to have 3 records with key fields 3, 4 and 5 respectively that are in the internal table
    what should be the correct way?

    Hi ,
    to delete all the records from dbtab
    DELETE dbtab.
    to update the database by using internal table
    -MODIFY dbtab       FROM TABLE itab.
    but as per my knowledge structures of internal table and database table should be same
    if the database table is a Ztable please change the structure of database table as you said
    Put fields 3,4and 5 as key fields
    Thanks & Regards,
    Sateesh.

  • Insert,  Delete and Update options in Table control

    Experts,
    I have writen code for Insert,  Delete and Update options in Table control. They are not working properly...
    can any one send the code for the above please...
    Thanks in advance..

    Hi,
    Following steps will help you.
    1.TOP-INCLUDE
    DATA: ITAB1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.
    DATA: ITAB2 LIKE KNA1 OCCURS 0 WITH HEADER LINE.
    DATA: WA LIKE KNA1.
    DATA: ANT TYPE I,CUR TYPE I.
    DATA: OK_CODE TYPE SY-UCOMM.
    CONTROLS: TABCTRL TYPE TABLEVIEW USING SCREEN 100.
    IN FLOWLOGIC
    PROCESS BEFORE OUTPUT.
    LOOP AT ITAB1 CURSOR CUR WITH CONTROL TABCTRL.
    ENDLOOP.
    PROCESS AFTER INPUT.
    MODULE CLEAR_DATA.
    LOOP AT ITAB1.
    MODULE MOVE_DATA.
    ENDLOOP.
    ADD “OK_CODE” IN ELEMENT LIST. CLICK ON LAYOUT AND  ADD TABLE CONTROL(name it as TABCTRL) AND PUSHBUTTONS AS FOLLOWS.
    SELECT THE FIELDS FROM PROGRAM. SAVE CHECK AND ACTIVATE.
    CLICK ON FLOWLOGIC EDITOR FROM APPLICATION TOOL BAR.
    DOUBLE CLICK ON MODULE “CLEAR_DATA”.
    write the in this module as below.
    CLEAR ITAB2. REFRESH ITAB2.
    DOUBLE CLICK ON MODULE “MOVE_DATA”.
    write the code in this module as below.
    APPEND ITAB1 TO ITAB2.
    ACTIVATE PAI AND WRITE THE CODE AS BELOW.
    CASE OK_CODE.
    WHEN 'FETCH'.
    SELECT * FROM KNA1 INTO TABLE ITAB1 UP TO 20 ROWS.
    TABCTRL-LINES = SY-DBCNT.
    WHEN 'ADD'.
    GET CURSOR LINE CNT.
    CNT = TABCTRL-TOP_LINE + CNT - 1.
    CLEAR WA.
    INSERT WA INTO ITAB1 INDEX CNT.
    WHEN 'MODIFY'.
    GET CURSOR LINE CNT.
    READ TABLE ITAB2 INDEX CNT.
    LOOP AT ITAB2.
    MODIFY KNA1 FROM ITAB2.
    ENDLOOP.
    SELECT * FROM KNA1 INTO TABLE ITAB1.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    ENDCASE.
    SAVE,CHECK AND ACTIVATE ALL.
    CREATE TCODE AND EXECUTE.
    contact if u hv any issues regarding this code.
    reward points,if it is useful.
    Thanks,
    Chandu.

  • Updating tableview back into database table

    I am trying to display a recordset from mysql database table into a tableview in javafx. Maybe let's say get all records where invoice number is 101 i n the master table from the child records in the child table.(This is a typical master detail scenario.) After this I update the tableview add, delete, edit some records AND then I want to save this Tableview or rather update it back, synchronise into the database table.
    I request you to kindly help with sample code or any guidelines that will help me in this objective.

    Here is the tutorial of tableView : http://docs.oracle.com/javafx/2/ui_controls/table-view.htm
    You can use the Java Class that mapped the database for ObservableList. Get all the record in the database and cover it to the java object. Then add them to the ObservableList to show on TableView. After add, update, edit,... Get the item in the ObservableList and update back to your database.
    I can't tell in detail. You should try this tutorial and if there are any more Specific Issue you can post another question here.

  • Locking multiple records in a database table at a time

    Hi Experts,
       I have a requirement to lock multiple records in the database table for writing. I have created lock object in SE11. But with this we have only 2 possibilities either lock entire table or lock a single record at a time.
       My requirement is, i have table with key field PROJECTID. I want more than one project to be locked, but not the complete table. I dont have any other field in the table to compare.
    Thanks in advance..
    Regards,
    Asrar

    Hi ,
    Try with FOR UPDATE in the SELECT sentence.
    SELECT FOR UPDATE *
        INTO Internal_Table
      FROM Table
    WHERE Conditions.
    UPDATE "Table_name" FROM TABLE  Internal_Table.
    COMMIT WORK.
    This sentence blocks only the records that satisfy of the WHERE conditions (not the entire table) and unlocks after commit work.
    Hope this information is help to you.
    Regards,
    José

  • How to updated the data into Database table

    Hi Guy's,
    Please help me Using Tabstrip control how to updated the related infotype records into related database table.
    Thanks and Regards,
    Sai.

    Hi Guy's,
    Please help me Using Tabstrip control how to updated the related infotype records into related database table.
    Thanks and Regards,
    Sai.

  • Need help to insert and update records in MDM

    Hi ,
    I am trying to develop an webdynpro application which can create and update records in tables of a repository of MDM . For example .. I want to insert values and later update values in Vendor table.
    I am new to webdynpro and MDM. If any one can help step by step or can send a sample code which I can be ready to use that would be great help.
    If anyone can have a sample code .. kindly mail to "[email protected]"
    It is urgent. Please help.
    Regards,
    Niraj
    Edited by: Niraj Kumar on May 23, 2008 6:50 AM

    Hi Niraj,
    Are u going to work with webdynpro Java/ABAP?
    some materials which are found useful are sent.
    Cheers,
    Mary

  • How to delete the child record from the database

    how to delete a parent and child record from the database can we do it in the servlet and my database is oracle

    I'm not sure I understand the question but you could certainly use the JDBC API from within your servlet to access and modify a DB. You could also use an EJB layer to access your DB and accomplish the same tasks.

  • Inserting multiple records in to database table using webdynpro abap

    Hi all,
    I have created a username inputfield,a button and a table
    with one coloumn.
    If i enter  names in the input field then the values should be
    displayed in that table.
    Even i have got the answer i am not able to insert
    the values in to database(ztable) table.
    i.e. only one value(1st) was inserted the second value was
    not inserted ....
    so kindly send me the coding to insert multiple records
    into the database table......
    by,
    ranjith

    hi Ranjith,
    If you want to insert multiple records from the webdynpro view table to database table then try the following code.
    DATA lo_nd_tablenode TYPE REF TO if_wd_context_node.
      DATA lo_el_tablenode TYPE REF TO if_wd_context_element.
      DATA ls_tablenode TYPE wd_this->element_tablenode.
      DATA it_tablenode LIKE STANDARD TABLE OF ls_tablenode.
      navigate from <CONTEXT> to <tablenode> via lead selection
      lo_nd_tablenode = wd_context->get_child_node( name = wd_this->wdctx_tablenode ).
      get element via lead selection
      lo_el_tablenode = lo_nd_tablenode->get_element(  ).
      get all declared attributes
      lo_nd_tablenode->get_static_attributes_table(
      IMPORTING
        table = it_tablenode ).
    MODIFY databasetablename FROM TABLE  it_tablenode.
    here it_tablenode is the internal table which holds the value from webdynpro view..
    Regards,
    Shamila.

  • Updating data in the database table

    Can any help me in the code for updating data in the database table.
    Regards,
    Rahul

    Hi Rahul,
    A slightly longer procedure that i'm adding here...
    1.) Create the component (i'm sure you have this covered)
    2.) Next on the button click that updates the database - add an action.
    3.) double click the action so that you are taken to the methods section of the view.
    4.) next you need to add the code that is required the update the database - this will be in the form of the above two posts.
    5.) compile and test the application
    Let me know in case you need further information on how to do this with a function module or something.
    Thanks.

  • Count Number of Records in Oracle Database Table

    Please help me to see if I "set" and "return" the number of records in my database table correctly (I am using the Oracle 9i):
       public int getNumberOfRecipientBeans() throws AssertionException, DatabaseException
          Connection conn = null;
          PreparedStatement stmt = null;
          String query = "SELECT count(*) FROM ContactEntry WHERE ContactTypeID = 6";
          ResultSet rs = null;
          try
             conn = DBConnection.getDBConnection();
             stmt = conn.prepareStatement( query );
             rs = stmt.executeQuery();
             // do I have to set anything here?
             if ( !rs.next() )
                throw new AssertionException("Assertion in servuce.getNumberOfRecipients");
              // Am I returning the counts here?
              return rs.getInt( 1 );
          catch( SQLException sqle )
             sqle.printStackTrace();
             throw new DatabaseException( "Error executing SQL in service.getNumberOfRecipients." );
          finally
             if ( conn != null )
                try
                   stmt.close();
                   stmt = null;
                   conn.close();
                catch( Exception Ex )
                   System.out.println( "Problem occurs while closing " + Ex );
                conn = null;

    public class MyE extends Exception {
        public MyE() {
            super(); // this line is not necessary. An empty method would suffice
        public MyE(String msg) {
            super(msg);
        // Check the API for Exception or Throwable--I may have the args backward
        public MyE(String msg, Throwable cause) {
            super(msg, cause);
        public MyE(Throwable cause) {
            super(cause);
    // Replace the log_warn() calls with appropriate logging calls for your context
    public class Closer {
        public static final void close(ResultSet closeMe) {
            if (closeMe != null) {
                try {
                    closeMe.close();
                catch (Throwable th) { log_.warn("Closing " + closeMe + ": ", th); }
        public static final void close(Statement closeMe) {
            if (closeMe != null) {
                try {
                    closeMe.close();
                catch (Throwable th) { log_.warn("Closing " + closeMe + ": ", th); }
        public static final void close(Connection closeMe) {
            if (closeMe != null) {
                try {
                    closeMe.close();
                catch (Throwable th) { log_.warn("Closing " + closeMe + ": ", th); }
        public static final void close(ResultSet rs, Statement stmt, Connection con) {
            close(rs);
            close(stmt);
            close(con);
    }

  • Selecting the last record from a database table

    In my ABAP Program, I have to use a select statement to retrieve the last record from the database table with the same key.  In other words, the Program will get more than one hit on the database table for the selected keys and I need to retrieve values from only the last record and not the first.  I know I can use an internal table to sort the records first and then retrieve the right value.   But to make things easier, is there a SELECT statement keyword than I can use to do this in one single step?  Thanks!

    hi,
    tables:mara.
        data: begin of it_mara occurs 0,
                matnr like mara-matnr,
                meins like mara-meins,
                mtart like mara-mtart,
                end of it_mara.
    select-options:s_matnr for mara-matnr.
    select matnr
              meins
              mtart
    from mara
    into table it_mara
    where matnr in s_matnr.
    if not it_mara[] is initial.
    sort it_mara by matnr descending.
    read table it_mara index 1.
    endif.
    then you get the last record of the select statement.
    reward points if useful,
    venkat.

Maybe you are looking for

  • Call ends at 3:13

    so me and my gf always skype in the evening and eventually we fall asleep while we're skype, in the morning when i wake up the call ended and it always ends at 3:13 at night. we asked people on facebook and they say its a hacker but i dont believe th

  • What r the diff types of schedule line categoriesr there ? purposes of its?

    what r the diff types of schedule line categoriesr there ? purposes of its?

  • Macbook Pro 2011 keeps freezing and disconnecting from internet

    Ever since I upgraded to 10.8 Mountain Lion, my macbook has been acting up and its becoming a real big hassle. The first big issue is it keeps freezing. Everything freezes, the only thing I can do is move my mouse cursor around but I can't open anyth

  • BEA WebLogic jDriver for Microsoft SQL Server

    Will BEA continue to support current and future installations of WebLogic jDriver for Microsoft SQL Server 2000 even though BEA recommends to use the JDBC driver available from Microsoft? A written response is necessary in order to determine our futu

  • After updates Apple TV and ipad won't wake mac

    Since the latest update to Maverick and new itunes and Apple TV software neither my ipad or Apple TV will load my library from itunes. I have to go to the imac and wake it myself. Home sharing is on, I have done a hard reset of my time capsule, reset