Difference update and insert

what is the difference between update and insert in the case of database tables?  what does update do  and what does insert do?

Hi,
Insert Functionality,
Inserts new lines in a database table.By default, data is only inserted in the current client. Data can only be inserted using a view if the view refers to a single table and was defined in the ABAP Dictionary with the maintenance status "No restriction".
Update Functionality,
Updates values in a database table. Normally, lines are updated only in the current client.
INSERT & UPDATE belongs to the Open SQL command set.
Thanks
Nimesh S. Patel

Similar Messages

  • Update and insert in to table

    Hi All,
    I am uploading data from a txt file into itab_infile and wants to update the table Zppprice based on itab_infile. It the record is existing it has to update and when it is a new record it has to insert the record. And I need to capture how many records havebeen updated and inserted.
    Please help me.
    Thanks,
    Veni.
    REPORT ZSD_PRICEPROTEC NO STANDARD PAGE HEADING
           LINE-SIZE 132
           LINE-COUNT 60.
    TABLES: KNA1,ZPPPRICE.
    TYPES: BEGIN OF type_infile,
             KUNNR(10) TYPE c,  "Customer Number
             MATNR(18) TYPE c,  "Material Number
             CRDATE(10) TYPE c,  "Creation Date
             EFDATE(10) TYPE c,  "Effective date
             SPRICE(15) TYPE c,  "Old Price
             EPRICE(15) TYPE c,  "New Price
             EOHQTY(09) TYPE c,  "Estimated Quantity
             AOHQTY(09) TYPE c.  "Actual Quantity
          TYPES: END OF type_infile.
    * Internal tables
    DATA: itab_infile TYPE STANDARD TABLE OF type_infile with header line.
    * Work areas
    DATA: wa_infile TYPE type_infile.
    * Global variables.
    DATA:  gc_tcode  LIKE sy-tcode VALUE 'VA01'. "Transaction code
    SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE text-001.
    PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK one.
    START-OF-SELECTION.
      PERFORM upload_text_file.
    *&      Form  UPLOAD_TEXT_FILE
    FORM upload_text_file.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                filename                = p_file
                filetype                = 'DAT'
           TABLES
                data_tab                = itab_infile
           EXCEPTIONS
                conversion_error        = 1
                file_open_error         = 2
                file_read_error         = 3
                invalid_type            = 4
                no_batch                = 5
                unknown_error           = 6
                invalid_table_width     = 7
                gui_refuse_filetransfer = 8
                customer_error          = 9
                OTHERS                  = 10.
      IF sy-subrc <> 0.
        MESSAGE e208(00) WITH 'Error in loading text file'.
      ENDIF.
    ENDFORM.                    " UPLOAD_TEXT_FILE

    Hi Veni,
    Simple thing ,you can use MODIFY Command,it works both insert as well update.
    check the documentation.
    see the below program and i am getting data from XLS file and i am updating to Ztable( same as ur case ).
    Program    : ZLWMI151_UPLOAD(Data load to ZBATCH_CROSS_REF Table)
    Type       : Upload program
    Author     : Seshu Maramreddy
    Date       : 05/16/2005
    Transport  : DV3K919574
    Transaction: None
    Description: This program will get the data from XLS File
                 and it upload to ZBATCH_CROSS_REF Table
    REPORT ZLWMI151_UPLOAD no standard page heading
                           line-size 100 line-count 60.
    *tables : zbatch_cross_ref.
    data : begin of t_text occurs 0,
           werks(4) type c,
           cmatnr(15) type c,
           srlno(12) type n,
           matnr(7) type n,
           charg(10) type n,
           end of t_text.
    data: begin of t_zbatch occurs 0,
          werks like zbatch_cross_ref-werks,
          cmatnr like zbatch_cross_ref-cmatnr,
          srlno like zbatch_cross_ref-srlno,
          matnr like zbatch_cross_ref-matnr,
          charg like zbatch_cross_ref-charg,
          end of t_zbatch.
    data : g_repid like sy-repid,
           g_line like sy-index,
           g_line1 like sy-index,
           $v_start_col         type i value '1',
           $v_start_row         type i value '2',
           $v_end_col           type i value '256',
           $v_end_row           type i value '65536',
           gd_currentrow type i.
    data: itab like alsmex_tabline occurs 0 with header line.
    data : t_final like zbatch_cross_ref occurs 0 with header line.
    selection-screen : begin of block blk with frame title text.
    parameters : p_file like rlgrap-filename obligatory.
    selection-screen : end of block blk.
    initialization.
      g_repid = sy-repid.
    at selection-screen on value-request for p_file.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                PROGRAM_NAME = g_repid
           IMPORTING
                FILE_NAME    = p_file.
    start-of-selection.
    Uploading the data into Internal Table
      perform upload_data.
      perform modify_table.
    top-of-page.
      CALL FUNCTION 'Z_HEADER'
      EXPORTING
        FLEX_TEXT1       =
        FLEX_TEXT2       =
        FLEX_TEXT3       =
    *&      Form  upload_data
          text
    FORM upload_data.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                FILENAME                = p_file
                I_BEGIN_COL             = $v_start_col
                I_BEGIN_ROW             = $v_start_row
                I_END_COL               = $v_end_col
                I_END_ROW               = $v_end_row
           TABLES
                INTERN                  = itab
           EXCEPTIONS
                INCONSISTENT_PARAMETERS = 1
                UPLOAD_OLE              = 2
                OTHERS                  = 3.
      IF SY-SUBRC <> 0.
        write:/10 'File '.
      ENDIF.
      if sy-subrc eq 0.
        read table itab index 1.
        gd_currentrow = itab-row.
        loop at itab.
          if itab-row ne gd_currentrow.
            append t_text.
            clear t_text.
            gd_currentrow = itab-row.
          endif.
          case itab-col.
            when '0001'.
              t_text-werks = itab-value.
            when '0002'.
              t_text-cmatnr = itab-value.
            when '0003'.
              t_text-srlno = itab-value.
            when '0004'.
              t_text-matnr = itab-value.
            when '0005'.
              t_text-charg = itab-value.
          endcase.
        endloop.
      endif.
      append t_text.
    ENDFORM.                    " upload_data
    *&      Form  modify_table
          Modify the table ZBATCH_CROSS_REF
    FORM modify_table.
      loop at t_text.
        t_final-werks = t_text-werks.
        t_final-cmatnr = t_text-cmatnr.
        t_final-srlno = t_text-srlno.
        t_final-matnr = t_text-matnr.
        t_final-charg = t_text-charg.
        t_final-erdat = sy-datum.
        t_final-erzet = sy-uzeit.
        t_final-ernam = sy-uname.
        t_final-rstat = 'U'.
        append t_final.
        clear t_final.
      endloop.
      delete t_final where werks = ''.
      describe table t_final lines g_line.
      sort t_final by werks cmatnr srlno.
    Deleting the Duplicate Records
      perform select_data.
      describe table t_final lines g_line1.
      modify zbatch_cross_ref from table t_final.
      if sy-subrc ne 0.
        write:/ 'Updation failed'.
      else.
        Skip 1.
        Write:/12 'Updation has been Completed Sucessfully'.
        skip 1.
        Write:/12 'Records in file ',42 g_line .
        write:/12 'Updated records in Table',42 g_line1.
      endif.
      delete from zbatch_cross_ref where werks = ''.
    ENDFORM.                    " modify_table
    *&      Form  select_data
          Deleting the duplicate records
    FORM select_data.
      select werks
             cmatnr
             srlno from zbatch_cross_ref
             into table t_zbatch for all entries in t_final
             where werks = t_final-werks
             and  cmatnr = t_final-cmatnr
             and srlno = t_final-srlno.
      sort t_zbatch by werks cmatnr srlno.
      loop at t_zbatch.
        read table t_final with key werks = t_zbatch-werks
                                    cmatnr = t_zbatch-cmatnr
                                    srlno = t_zbatch-srlno.
        if sy-subrc eq 0.
          delete table t_final .
        endif.
        clear: t_zbatch,
               t_final.
      endloop.
    ENDFORM.                    " select_data
    Thanks
    Seshu

  • Use of the "updlock" hint with update and insert statements

    I have inherited some stored procedures and am trying to figure out why the developers decided to use the "updlock" hint on many of the update and insert statements. I have looked around everywhere and have found only one explanation of why "update...with
    (updlock)" can be useful, namely when a table has no clustered index:
    http://www.sqlnotes.info/2012/10/10/update-with-updlock/ I have found nothing yet that mentions why "insert into...with (updlock)" might be used. I understand why the hint
    might be useful on select statements in some cases, but if all of the tables have clustered indexes, is there any good reason to use it on update and insert statements?
    Thanks,
    Ron
    Ron Rice

    This form of deadlock error can occur on a table which has a clustered index.
    If you are doing updates on a table which has a clustered index and that table also has a nonclustered index and the nonclustered index is used to find the row to update you can see this type of deadlock.  For example create a table with a clustered
    primary key index and a nonclustered index by running
    Create Table Foo(PK int primary key identity, OtherKey varchar(10), OtherData int);
    go
    Insert Foo Default Values;
    go 10000
    Update Foo Set OtherKey = 'C' + Cast(PK As varchar(10))
    Create Unique Index FooIdx On Foo(OtherKey);
    That creates a table with 10000 rows, a clustered index and a nonclustered index.  Then run
    Begin Transaction
    Update Foo Set OtherData = 1 Where OtherKey = 'C5'
    That will use the FooIdx index to find the row that needs to be updated.  It will get a U lock on the index row in the FooIdx index, then an X lock on the row in the clustered index, update that row, then free the U lock on FooIdx, but keep the X lock
    on the row in the clustered index.  (There is other locking going on, but to simplify things, I'm only showing the locks that lead to the deadlock).
    Then in another window, run
    Begin Transaction
    Update Foo Set OtherData = 2 Where OtherKey = 'C5'
    This will get a U lock on the index row in the FooIdx index, then try to get an X lock on the row in the clustered index.  But that row is already exclusively locked, so this second window will wait holding a U lock on FooIdx row and is waiting for
    an X lock on the clustered index row.
    Now go back to the first window and run
    Update Foo Set OtherData = 3 Where OtherKey = 'C5'
    This will once again try to get the U lock on the FooIdx row, but it is blocked by the U lock the second window holds.  Of course the second window is blocked by the X lock on the clustered index row and you have a deadlock.
    All that said, I certainly do not routinely code my updates with UPDLOCK.  I try to design databases and write code so that deadlocks will be rare without holding excessive locks.  The more locks you hold and the longer you hold them, the more
    blocking you will get and the slower your system will run.  So I write code that if a deadlock exception occurs, it is properly handled.  Then if too many deadlocks occur, that is the time to go back to the code to see what changes are needed to
    decrease the number of deadlocks (one way to do that may be to get locks earlier and/or hold them longer. 
    But I wouldn't worry much about this form of deadlock.  It is, in my experience, vary rare.  I don't recall ever seeing it in a production environment.
    Tom

  • 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

  • Rows updated and inserted by  MERGE

    Hi,
    Is there any way I can come to know, How many rows are updated and inserted using a MERGE statement.
    Thanks in advance

    Something like this ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>
    satyaki>desc aud_emp;
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    AUDIT_TMP                                          TIMESTAMP(6)
    AUDIT_IP_ADDR                                      VARCHAR2(15)
    OPR_DESC                                           VARCHAR2(30)
    USER_NM                                            VARCHAR2(40)
    REMARKS                                            VARCHAR2(200)
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>select * from aud_emp;
    no rows selected
    Elapsed: 00:00:00.04
    satyaki>
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>select * from e_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81    3718.75                    20
          7782 CLARK      MANAGER         7839 09-JUN-81     3062.5                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82      11700                    10
    7 rows selected.
    Elapsed: 00:00:00.07
    satyaki>CREATE OR REPLACE TRIGGER trg_aud
    before insert or update or delete on e_emp
    for each row
    declare
         S_IP_ADDR    varchar2(30);
         str          varchar2(320);
         s_empno      varchar2(40);
         s_ename      varchar2(40);
         s_job        varchar2(40);
         s_mgr        varchar2(40);
         s_hrdate     varchar2(40);
         s_sal        varchar2(40);
         s_comm       varchar2(40);
         s_deptno     varchar2(40);
    begin
         SELECT SYS_CONTEXT('USERENV','IP_ADDRESS')
         into S_IP_ADDR
         from dual;
         str:= null;
         if inserting then
             insert into aud_emp values(:new.empno,
                                        :new.ename,
                                        :new.job,
                                        :new.mgr,
                                        :new.hiredate,
                                        :new.sal,
                                        :new.comm,
                                        :new.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'INSERT',
                                        USER,
                                        NULL);
         elsif updating then
           if :old.empno <> :new.empno then
              s_empno := 'Employee No: '||:old.empno;
           elsif :old.ename <> :new.ename then
              s_ename := 'Employee Name: '||:old.ename;
           elsif :old.job <> :new.job then
              s_job := 'Job: '||:old.job;
           elsif :old.mgr <> :new.mgr then
              s_mgr := 'Mgr: '||:old.mgr;
           elsif :old.hiredate <> :new.hiredate then
              s_hrdate := 'Hire Date: '||:old.hiredate;
           elsif :old.sal <> :new.sal then
              s_sal := 'Salary: '||:old.sal;
           elsif :old.comm <> :new.comm then
              s_comm := 'Commission: '||:old.comm;
           elsif :old.deptno <> :new.deptno then
              s_deptno := 'Department No: '||:old.deptno;
           end if;
           str:= 'Updated Records Details -> '||s_empno||' '||s_ename||' '||s_job||' '||s_mgr||' '||s_hrdate||' '||s_sal||' '||s_comm||' '||s_deptno;
             insert into aud_emp values(:new.empno,
                                        :new.ename,
                                        :new.job,
                                        :new.mgr,
                                        :new.hiredate,
                                        :new.sal,
                                        :new.comm,
                                        :new.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'UPDATE',
                                        USER,
                                        str);
         elsif deleting then
             insert into aud_emp values(:old.empno,
                                        :old.ename,
                                        :old.job,
                                        :old.mgr,
                                        :old.hiredate,
                                        :old.sal,
                                        :old.comm,
                                        :old.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'DELETE',
                                        USER,
                                        'Old Records before deletion');
         end if;
    exception
        when others then
          raise_application_error(-20501,'Contact With Your Admin....');
    end;
    Trigger Created.
    Elapsed: 00:00:00.09
    satyaki>ed
    Wrote file afiedt.buf
      1  merge into e_emp o
      2     using emp n
      3     on ( o.empno = n.empno)
      4     when matched then
      5       update set o.ename = n.ename,
      6                  o.job   = n.job,
      7                  o.mgr   = n.mgr,
      8                  o.hiredate = n.hiredate,
      9                  o.sal = n.sal,
    10                  o.comm = n.comm,
    11                  o.deptno = n.deptno
    12     when not matched then
    13       insert( o.empno,
    14               o.ename,
    15               o.job,
    16               o.mgr,
    17               o.hiredate,
    18               o.sal,
    19               o.comm,
    20               o.deptno)
    21       values( n.empno,
    22               n.ename,
    23               n.job,
    24               n.mgr,
    25               n.hiredate,
    26               n.sal,
    27               n.comm,
    28*              n.deptno)
    satyaki>/
    13 rows merged.
    Elapsed: 00:00:03.95
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.07
    satyaki>
    satyaki>
    satyaki>select * from aud_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO AUDIT_TMP                                                                   AUDIT_IP_ADDR   OPR_DESC                       USER_NM                                  REMARKS
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20 31-DEC-08 10.54.06.667000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 3718.75
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10 31-DEC-08 10.54.06.686000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 3062.5
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20 31-DEC-08 10.54.06.687000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7839 KING       PRESIDENT            17-NOV-81       7000                    10 31-DEC-08 10.54.06.697000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 5000
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20 31-DEC-08 10.54.06.698000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20 31-DEC-08 10.54.06.699000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30 31-DEC-08 10.54.06.720000 PM                                                10.23.99.77     INSERT                         SCOTT
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10 31-DEC-08 10.54.07.059000 PM                                                10.23.99.77     INSERT                         SCOTT
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30 31-DEC-08 10.54.07.060000 PM                                                10.23.99.77     INSERT                         SCOTT
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30 31-DEC-08 10.54.07.060000 PM                                                10.23.99.77     INSERT                         SCOTT
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30 31-DEC-08 10.54.07.061000 PM                                                10.23.99.77     INSERT                         SCOTT
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO AUDIT_TMP                                                                   AUDIT_IP_ADDR   OPR_DESC                       USER_NM                                  REMARKS
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10 31-DEC-08 10.54.07.061000 PM                                                10.23.99.77     INSERT                         SCOTT
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30 31-DEC-08 10.54.07.062000 PM                                                10.23.99.77     INSERT                         SCOTT
    13 rows selected.
    Elapsed: 00:00:00.22
    satyaki>
    satyaki>set lin 80Hope this will help you.
    Regards.
    Satyaki De.

  • Mutilple updations and insertions by BAPI_SALESORDER_CHANGE at one time

    Hi ,
    I just want to know whether it is possible to insert and update multiple line items in a sales order through the BAPI BAPI_SALESORDER_CHANGE .
    we tried doin it for single record ( update and insert ) , it is working fine . but when we try for mutiple items , it gives a system dump.
    could you plz help out , how to pass the parameters for mutiple updation and insertions at a time?

    HI ALL,
    I THINK IF WE MAKE THE SCHEDULE LINE ITEM NO. TO BE UNIQUE FOR EACH LINE ITEM IT GETS UPLOADED PROPERLY. THE VBEP-ETENR IS 001 ONLY. PEOPLE WITH ALTERNAT ANSWERS PLZ. CORRECT.
    SEE CODES BELOW.
    **This creates additional line no. in the sales order.
    **Material no is hard coded, you need to change the materisl no in
    **available in ur system.
    T_ITEM-itm_number = ''.
    T_ITEM-material = 'AGA350'.
    T_ITEM-target_qty = '2'.
    APPEND T_ITEM.
    T_ITEMx-itm_number = ''.
    T_ITEMX-UPDATEFLAG = 'I'.
    T_ITEMX-target_qty = 'X'.
    T_ITEMX-material = 'X'.
    APPEND T_ITEMX.
    T_SCHE-SCHED_LINE = '1'.
    T_SCHE-REQ_QTY = 2.
    t_sche-req_date = '20080204'.
    APPEND T_SCHE.
    T_SCHEX-updateflag =  c_insertflag.
    t_schex-req_date = 'X'.
    T_SCHEX-SCHED_LINE = '1'.
    t_schex-req_qty = 'X'.
    APPEND T_SCHEX.
    **This also creates additional line no. in the sales order.
    **Material no is hard coded, you need to change the materisl no in
    **available in ur system.
    *T_ITEM-itm_number = ''.
    T_ITEM-material = 'AGA350'.
    T_ITEM-target_qty = '1'.
    APPEND T_ITEM.
    *T_ITEMx-itm_number = ''.
    T_ITEMX-UPDATEFLAG = 'I'.
    T_ITEMX-target_qty = 'X'.
    T_ITEMX-material = 'X'.
    APPEND T_ITEMX.
    T_SCHE-SCHED_LINE = '4'.
    t_sche-req_date = '20080202'.
    T_SCHE-REQ_QTY = 1.
    APPEND T_SCHE.
    T_SCHEX-updateflag =  c_insertflag.
    t_schex-req_date = 'X'.
    T_SCHEX-ITM_NUMBER = 'X'.
    T_SCHEX-SCHED_LINE = '4'.
    T_SCHEX-REQ_QTY = 'X'.
    APPEND T_SCHEX.
    **This also creates additional line no. in the sales order.
    **Material no is hard coded, you need to change the materisl no in
    **available in ur system.
    *T_ITEM-itm_number = ''.
    T_ITEM-material = 'AGA350'.
    T_ITEM-target_qty = '1'.
    APPEND T_ITEM.
    *T_ITEMx-itm_number = ''.
    T_ITEMX-UPDATEFLAG = 'I'.
    T_ITEMX-target_qty = 'X'.
    T_ITEMX-material = 'X'.
    APPEND T_ITEMX.
    T_SCHE-SCHED_LINE = '5'.
    t_sche-req_date = '20080202'.
    T_SCHE-REQ_QTY = 1.
    APPEND T_SCHE.
    T_SCHEX-updateflag =  c_insertflag.
    t_schex-req_date = 'X'.
    T_SCHEX-ITM_NUMBER = 'X'.
    T_SCHEX-SCHED_LINE = '5'.
    T_SCHEX-REQ_QTY = 'X'.
    APPEND T_SCHEX.
    **This also creates additional line no. in the sales order.
    **Material no is hard coded, you need to change the materisl no in
    **available in ur system.
    *T_ITEM-itm_number = ''.
    T_ITEM-material = 'AGA350'.
    T_ITEM-target_qty = '1'.
    APPEND T_ITEM.
    *T_ITEMx-itm_number = ''.
    T_ITEMX-UPDATEFLAG = 'I'.
    T_ITEMX-target_qty = 'X'.
    T_ITEMX-material = 'X'.
    APPEND T_ITEMX.
    T_SCHE-SCHED_LINE = '6'.
    t_sche-req_date = '20080202'.
    T_SCHE-REQ_QTY = 1.
    APPEND T_SCHE.
    T_SCHEX-updateflag =  c_insertflag.
    t_schex-req_date = 'X'.
    T_SCHEX-ITM_NUMBER = 'X'.
    T_SCHEX-SCHED_LINE = '6'.
    T_SCHEX-REQ_QTY = 'X'.
    APPEND T_SCHEX.
    *i_order_header_in-sd_doc_cat

  • Possible to update and insert in a table at a same time

    Hi friends,
    I have a table with six columns in it.
    Initially that table will have seven rows with six columns, but all the columns wont have a content in it. But only one column will have the content of seven rows. so that's why initially it will have seven rows.
    Assume that first column consist of the following seven content each in a row(so seven row)
    *)A
    *)B
    *)C
    *)D
    *)E
    *)F
    *)G
    So what i need to do is set DML operation such that for the existing seven rows which is in the table i need to update the value of the remaining six column and at the same time i need to insert all the seven rows of only the first column in the next seven rows.
    Whether it is possible to do it.
    How to achieve it friends,
    Thanks
    Regards,
    Mini

    Hi,
    It should be like
    Initially my table would be like the below
    *questions            StronglyAgree              DA               AG          suggestions*
    what is ur name?          
    what is ur age?                                 
    which is ur pet?                                    My DML operation should be like it should update and insert
    Update in the sense, it should be like
    *questions            StronglyAgree              DA               AG                    suggestions*
    what is ur name?              y                                                                my name
    what is ur age?                                        y                                        my age
    which is ur pet?                                                         y                       my petSoon after that insert should be like
    *questions            StronglyAgree              Disagree             Agree                    suggestions*
    what is ur name?              y                                                                          my name
    what is ur age?                                          y                                                 my age
    which is ur pet?                                                                y                          my pet
    what is ur name?
    what is ur age?
    which is ur pet?It should be like the above..
    All izz well
    GTA
    Edited by: GTA on Jun 13, 2011 6:43 AM
    Edited by: GTA on Jun 13, 2011 6:43 AM

  • How can we do policy updations and insertion using procedures in insurence?

    how can we do policy updations and insertion using procedures in insurence?
    please answer for this post i need faced in interview.how can we write the code for that procedure in policy details using procedures in plsql.

    997995 wrote:
    how can we do policy updations and insertion using procedures in insurence?
    please answer for this post i need faced in interview.how can we write the code for that procedure in policy details using procedures in plsql.You are asking about a specific business area (Insurance) and the nuances of that business (Insurance Policies) and providing no technical details about what is required, on a technical forum. There are many varied businesses in the world and not everyone here is going to be familiar with the area of business you are referring to.
    As a technical forum, people are here to assist with technical issues, not to try and help you answer questions in an interview for something you clearly know nothing about, so that you can get a job that you won't know how to do.
    If you have a specific technical issue, post appropriate details, including database version, table structures and indexes, example data and expected output etc. as detailed in the FAQ: {message:id=9360002}

  • Creation of a Single button for both Update and Insert

    Hi,
    I want to create a button which performs both Insert and Update function. As of now i have 2 seperate buttons. Can I combine them in to one by writing a procedure which checks for the data in the database...If the record exists, then it should update the record, if not it should insert...Please guide me
    Regards,
    Pa

    Hi,
    If I am inserting in to the table a new record, how do I check for that column in the table...
    It should work this way..
    I have a list of users in a page, if I click on any user name, it will redirect me to another screen which will allow me to create a record for the selected user name. I want to check the selected user name in the table. If it is already existing then need to update, else insert.
    Regards,
    Pa

  • Updating and inserting on Long Raw column

    Hi All,
    My source table contains LONG RAW column in XX databse. I have to fetch the data from this table in YY Databse using DB link and insert into same structured table. The problem is, i can not access the LONG RAW data for some rows which the size exceeding above 32k.
    My requirement is, i have to fetch and insert or update the record(Source and target table structure is same and dtabase is different).
    Please suggest the best way of handle this problem.
    Please let me know if you need more information.
    Thanks
    Ram
    Edited by: ram on Oct 19, 2008 2:11 PM
    Edited by: ram on Oct 19, 2008 2:12 PM

    We using the procedure to insert and update. Procedure will called to update or insert only one record at a time from XX databse to YY database.
    We are not using SQL * PLUS for this operation.
    Thanks
    Ram

  • How to update and insert  automatically

    Hi all,
    I am having two tables, old and new (first column is PKey in two tables)
    NEW
    5     col2     col3     col4
    6     col2     col3     col4
    1     col2     col3     col44
    2     col2     col3     col4
    3     col2     col33     col4
    4     col2     col3     col4
    OLD
    1     col2     col3     col4
    2     col2     col3     col4
    3     col2     col3     col4
    4     col2     col3     col4
    I want to update/insert in OLD table from the NEW tables values.
    I think i will use MERGE statement, but sometimes, the column value will
    change (PKey didnot change), so MERGE wont work here.
    With MINUS statement, i will get the differences
    select COL1, COL2, COL3, COL4
    from NEW
    minus
    select COL1, COL2, COL3, COL4
    from OLD;
    1     col2     col3     col44
    3     col2     col33     col4
    5     col2     col3     col4
    6     col2     col3     col4
    I want to update/insert these values Remotely in OLD (OLD table actually in Remote). I cannot send all the data of NEW table to remote because the data is very large. So, i have to take the differences and i have to send those differences to Remote and i have to update/insert remotely.
    Any help is appreciated.
    Thanks in advance
    Pal

    try like this:
    merge
    into old t
          using (
                  select COL1, COL2, COL3, COL4
                    from NEW
                  minus
                  select COL1, COL2, COL3, COL4
                    from OLD
                ) v
             on (v.col1 = t.col1)
    when matched
       then update set t.col2 = v.col2, t.col3 = v.col3, t.col4 = v.col4
    when not matched
       then insert(col1, col2, col3, col4) values(v.col1, v.col2, v.col3, v.col4)

  • Handling update and insert in a database table

    Hi guys,
    I have some data in a database table which I created.Every day some new records come into the table.what i want is that if the account no of the new record which comes say today already exists in the table hen I do not insert a new record but only update the value field related to the account no.
    Being more explicit:
    say my table has two columns
    acc no        value.
    10                3500
    Now as for the existing account no 10 say a new value 300 comes in I want that a new field is not created rather the value is made to 3500+300.
    and if an accno 20 comes which is not there in table a new row is aded for that.
    Any suggestions would be appreciated.
    Thanks

    Hi
    you can do the following way.
    report ztest.
    data: begin of itab occurs 0,
            accno type char10,
            value type i,
          end of itab.
    data: it_acc like itab occurs 0 with header line,
          it_acc1 like itab occurs 0 with header line.
    Assume already value in itab.
    select *
      into table it_acc
      from zacc
        for all entries in table itab.
    where accno eq itab-accno.
    loop at it_acc.
      collect it_acc to it_acc1.
    endloop.
    loop at itab.
      collect itab to it_acc1.
    endloop.
    modify zacc from table it_acc1.
    Reward points, if it is useful.
    Regards
    Raja.
    Edited by: Ravindra Raja on May 28, 2008 5:38 PM

  • Problem while update and insert data in table

    Hi All,
    I have problem while save line data....
    I have an advance table.I take remove and duplicate line in message choice of advance table action layout.
    Also there is one temp table to save Po number data which is populated in advance table according to PO Number search.And In Temp table record number is column which use
    to insert and update data in temp table which mention in procedure
    Problem is that : When i Searched PO Number and duplicate line and save that record it insert a new line always and it insert record according to duplicate line no .It not update previous line,insert new line always according to duplicate line no.
    Please tell me what is solution?
    Thanks,
    Neil

    Hi,
    I am not cleared with your requirement.
    If possible send me the screenshots for the same.
    --Sushant
    [email protected]

  • Database Updation and Insertion using Modify Statement

    Hi All,
    I am using Modify statment for data insertion and updation
    MODIFY zmpit_ven_bgg_rg FROM TABLE t_ven_bgg .
    But I am getting error
    The type of the database table and work area (or internal table) "T_VEN_BGG" are not compatible.
    I have defined my internal table of below type :
    TYPES : BEGIN OF ty_ven_bgg,
            mandt             TYPE mandt,
            lifnr                 TYPE lfa1-lifnr,
            bgg                 TYPE zmpit_ven_bgg_rg-matkl,
            ind                  TYPE zmpit_ven_bgg_rg-active_ind,
            created_by      TYPE zmpit_ven_bgg_rg-created_by,
            created_on      TYPE zmpit_ven_bgg_rg-created_on,
            last_changed_by TYPE zmpit_ven_bgg_rg-last_changed_by,
            last_changed_on TYPE zmpit_ven_bgg_rg-last_changed_on,
            remarks              TYPE zmpit_ven_bgg_rg-remarks,
            ind1(1)                TYPE c,
                 END OF ty_ven_bgg.
    Here, ind1 is not field  of the table.
    I have added a new field Remarks in the table and thus i included it in the Internal table also.
    Above Modify statement was working fine without Remarks field. I am not able to understand the error
    as work area is also of type ty_ven_bgg.
    Please suggest some solution.
    Regards,
    Nibha

    Hi,
    Though you have creaated one more internal tsble without the indc field, but you can do it using the same intrenal table by simply using
    1. MOVE-CORRESPONDING <internal table> to <ztable>.
    2.MODIFY <ztable>.
    will solve your problem
    Secondly declare the internal table using DATA after structure has been declared using TYPES.
    This is better approach to follow.
    Pooja

  • How to tell between update and insert ?

    I have a form where a user can enter a value, press a button and anoher input would appear, add another value, press the button again, etc. When done, he submits and I use cfloop list to insert the data into a table.
    When I bring up this form again, I check to see if there are any values in the table. If they are there, I display the values in a table, one per row.  At the end, I have the button again, just in case they need to add more values.
    Here is the problem that I am running into and do not know how to solve. How do I know whether they added a new value, or simply changed one of the existing values ? Or what is they did both, change an exisitng value and add a new value ?
    This is the code I use if they chagned an exisitng value :
    <cfloop index="dateCodeID" list="#form.dateCodeID#" delimiters=",">
    <cfquery name="qryUpdateDateCodes" datasource="db">
    udate table
         set dateCode = '#Evaluate("form.dateCode#dateCodeID#")#'
        where stockScreenID = '#form.stockScreenID#'
    and dateCodeID = '#dateCodeID#'
    </cfquery>
    </cfloop>
    and I would use the cfloop list to insert a new value, but how would I know which one to use when they submit ? I do not know whether an exisitng value(s) changed or new value(s) added.
    Thanks

    So if I have three existing values displayed, and add a new one, would I first loop thru the insert to check for the three existing records, and then insert the new record if no insert is performed ?
    You would loop and call the stored procedure once for each record to be handled.  The stored procedure contains the logic to handle the insert or update determined by whether or not a record with the matching primary key value exists in your table. Some databases have built in functionality to handle insert or update logic for you.  Microsoft SQL Server 2008 has MERGE ( http://msdn.microsoft.com/en-us/library/bb510625.aspx ) and MySQL has INSERT ON DUPLICATE KEY UPDATE ( http://dev.mysql.com/doc/refman/6.0/en/insert-on-duplicate.html ).
    Is the statement IF ( COUNT_OF_RECORDS_UPDATED = 0 ) the actual statement to check for udpated records ? 
    Yes, this statment is used to determine if the previous statement updated any records in the database.  The exact syntax will depend on your database server version.
    What if I update only one of the three existing records, and also add a new record ?
    I'm not sure I follow you.  Perhaps if you could post your ColdFusion and SQL code we could offer better responses.  You might also post a SQL specific question in a forum for your database version.

Maybe you are looking for

  • How can I search multiple columns in a SQL command of Union tables

    Hi: We have a database with tables that are nearly identical that we use for production and production history. I have created an SQL command in Crystal 2008 to joins several of the tables and then added a "UNION" to connect the History and Prod tabl

  • SET THE VALUE TO VALIDATE THE VALUE IN APEX

    GOOD DAY MASTER PLEASE HELP ME ON THIS I HAVE A POPUP LOV (ITEM_NAME) THAT COMING TO DATABASE VIEW UNDER THAT POPUP LOV I CREATED A DYNAMIC ACTION (SET VALUE) WHERE WHEN THE USER CLICK THE POPUP LOV(ITEM_NAME) AND PICK A ITEM IT WILL SET VALUE OF QTY

  • Can't open Bootcamp Assistant in Mac OS

    Today I tried to install win 8 on my computer, as I intended to intall it through U disk. I googled and revised the info.plist in the bootcamp assistant.  Then, the picture changed into this:  , I ca't open it since then. What can i do?

  • Getting error when trying to download update for flash player with OSX 10.91

    Trying everything to download update for Adobe Flash Player. This is maddening. I have tried uninstalling previous player and re-installing and checked my preferences. Can any one give me some instructions that are easy to understand. I keep getting

  • Inheritance in DAOs from a MainDAO???

    I'm thinking of making a central dao with code that daos will use to connect to DB then extending the maindao for the minor daos, so in case I change something I will not have to waste time on maintence, bad idea?