Insert Records into database table.

Hello Friends,
                     I am trying to insert set of records from an Internal table into Database table.
INSERT SPFLI FROM TABLE ITAB ACCEPTING DUPLICATE KEYS.
This is my statement. But It inserts only one record in to SPFLI table.
Cheers
Senthil

Hi Sentil,
USE THIS STATEMENT.
MOVE-CORRESPONDING ITAB TO SPFLI.
SPFLI-MANDT = SY-MANDT.
MODIFY SPFLI.
thy this....
<b>reward if useful</b>
regards,
sunil kairam.

Similar Messages

  • Validations when inserting records into database using table control?

    hi , guru's.
          iam inserting records into database table through table control when i press insert i want check which record is existing and which is not . so please give me any sample code
    regards,
    satheesh.

    hi , arjun.
    please check this code.
        WHEN 'INSERT'.
        data: g_vcontrol_itab1 like table of zcust_call_rec,
              g_vcontrol_wa1 like g_vcontrol_wa.
         SELECT *  FROM zcust_call_rec
                   INTO CORRESPONDING FIELDS OF TABLE g_vcontrol_itab1
                   FOR ALL ENTRIES IN g_vcontrol_itab
                   WHERE kunnr = g_vcontrol_itab-kunnr AND budat = g_vcontrol_itab-budat.
            loop at g_vcontrol_itab into g_vcontrol_wa.
               read table g_vcontrol_itab1 into g_vcontrol_wa1
                    with table key  g_vcontrol_wa-kunnr = kunnr and g_vcontrol_wa-budat = budat.
                     if sy-subrc = 0.
                       delete g_vcontrol_itab.
                     endif.
            endloop.
          LOOP AT g_vcontrol_itab INTO g_vcontrol_wa.
            INSERT into zcust_call_rec values g_vcontrol_wa.
          ENDLOOP.
    with this iam getting error message like this.
              <b>g_vcontrol_wa-budat is not expected.</b>

  • Inserting new records into database table at runtime

    Hi all ,
    How to insert new records into database table at runtime on click update?
    Thanks.

    Hi Sasikala,
    Just for your understanding am giving a sample code snippet which you can use to read the contents of your Table UI element & save the data on to your database. Suppose you have a button up on pressing which you want to read the data from your screens table & save on to the database then you can proceed as shown below:
    1) Obtain the reference of your context node.
    2) Fetch all the data present in your table into an internal table using methods of if_wd_context_node
    3) Use your normal ABAP logic to update the database table with the data from your internal table
    In my example I have a node by name SFLIGHT_NODE and under this I have the desired attributes from SFLIGHT. Am displaying these in an editable table & the user would press up on a push button after making the necessary changes to the tables data. I would then need to obtain the tables information & save on to the database.
    data: node_sflight           type ref to if_wd_context_node,
            elem_sflight           type ref to if_wd_context_element,
            lt_elements            type WDR_CONTEXT_ELEMENT_SET,
           stru_sflight           type if_main=>element_sflight_node,
           it_flights             type if_main=>elements_sflight_node.
    "   navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
        node_sflight_node = wd_context->get_child_node( name = 'SFLIGHT_NODE'  ).
       lt_elements = node_sflight->get_elements( ).
    "   Get all the rows from the table for saving on to the database
        loop at lt_elements into elem_sflight.
          elem_sflight->get_static_attributes( importing static_attributes = stru_sflight ).
          append stru_sflight to it_flights.
        endloop.
    " Finally save the entries on to the database
        modify ZSFLIGHT99 from table it_flights.
        if sy-subrc eq 0.
    endif.
    However a word of caution here.... SAP doesn't ever recommend directly modifying the database through an SQL query. You would preferably make use of a BAPI for the same. Try go through Thomas Jung's comments in [here|modify the data base table which is comming dynamiclly;.
    Regards,
    Uday

  • Retrive last inserted  record  from database table

    Hi,
    some body inserting a record into table 'A' through some procedure/java program.i want to retrive the last inserted record from database table.records are not stored in order.Can any body help me.

    In general, unless you are storing a timestamp as part of the row or you have some sort of auditing in place, Oracle has no idea what the "first" or "last" record in a table is. Nor does it track when a row was inserted.
    - If you have the archived logs from the point in time when the row was inserted, you could use LogMiner to find the timestamp
    - If the insert happened recently (i.e. within hours), you may be able to use flashback query to get the value
    - If you're on 10g or later and the table was built with ROWDEPENDENCIES and the insert happened in the last few days and you can deal with a granularity of a few seconds and you don't need 100% accuracy, you could get the ORA_ROWSCN of the row and convert that to a timestamp.
    If this is something you contemplate needing, you need to store the data in the row or set up some sort of auditing.
    Justin

  • Can BO Enterprize SDK inserts records into user table

    From Infostore can we create a jsp script using Java SDK to inserts records into user table??
    Thanks
    Amar

    Hi Amar,
    I want to retrieve data/records from Infostore and insert into a user table using JSP script. Is it possible to do this?
    Infostore is a database used by BO Server. so any changes made in infostore through BO enterprise session is valid.
    Say u want to retrive on of report present in folder <my folder>.
    The you have to query for that. for eg.
    boinfostore.query("select * from ci_infoobjects where si_kind ='report' and si_foldername='my folder'");
    Create/add/insert any new information in infostore is done by functionalities provide by SDK.
    like adding the user or scheduling a report will add new object to infostore.
    If you directly access cms database and make any changes then , I am afraid you will end up with nightmare.
    So it is always recommneded to access infostore/ cms database only from bo session.
    For more information refer below link
    [http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/devsuite.htm]
    then under Contents
    BusinessObjects Enterprise SDK >>  COM developer guide and API reference >> Query Language Reference
    do revert if any queries
    Thanks,
    Praveen.

  • Inserting records into a table with all caps

    Hello
    I have a procedure that inserts records into a table. How do I ensure that the text values inserted are recorded all capital letters into the table?
    Thanks.

    You can use UPPER(..) function in your insert statement, so that values are converted to UPPER, before insert.
    If you want to check at table level, you can achieve that by writting a before insert trigger and in that trigger check
    IF UPPER(:new.<col>) != :new.<col> THEN
    RAISE_APPLICATION_ERROR(-20101,'Error: Not all values are in upper case')
    END IF;

  • Its very urgent:how to insert data into database tables

    Hi All,
    I am very new to oaf.
    I have one requirement data insert into database tables.
    here createPG having data that data insert into one custom table.
    but i dont know how to insert data into database tables.
    i wrote the code in am,co as follows.
    in am i wrote the code:
    public void NewoperationManagerLogic()
    ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();
    OADBTransaction oadbt=getOADBTransaction();
    if(!vo1.isPreparedForExecution())
    vo1.executeQuery();
    Row row=vo1.createRow();
    vo1.insertRow(row);
    in createPG processrequest co:
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.NewoperationManagerLogic();
    process form request:
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    if(pageContext.getParameter("Submit")!=null)
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.getOADBTransaction().commit();
    please help with an example(sample code).
    its very urgent.
    thanks in advance
    Seshu
    Edited by: its urgent on Dec 25, 2011 9:31 PM

    Hi ,
    1.)You must have to create a EO based on custom table and then VO based on this EO eventually to save the values in DB
    2.) the row.setNewRowState(Row.STATUS_INITIALIZED); is used to set the the status of row as inialized ,this is must required.
    3.) When u will create the VO based on EO the viewattributes will be created in VO which will be assigned to the fields to take care the db handling .
    You must go thtough the lab excercise shipped with you Jdeveloper ,there is a example of Create Employee page ,that will solve your number of doubts.
    Thanks
    Pratap

  • Using Crystal 2008 to insert records into a table

    Hi,
    We have a unique need to use Crystal to insert records into a table. We have managed to test a report that can write into a temporary table.  This is done by using sql command object  and uses  the following code :
    INSERT INTO TEMP_TABLE  (ORDERID)
    VALUES ({?orderid})   (-- where orderid a parameter).
    This test report asks for an order id and then inserts the record perfectly fine.
    Now moving on to the real report - This report basically prints orders in batches and we want to insert order id into a temporary table to ensure we don't print orders that were already printed. To do this we created a sub report "insert orders" that has the above insert command. The main report passes the orderid to subreport and the idea is that the subreport would insert each time an order is passed. So if main report printed 50 orders ids, the then it would do 50 inserts individually into the temp table. 
    This however is NOT working. The report runs fine but there is no insert.  Our hunch is that  Crystal is not committing after every order id is passed from the main report.  Not sure if we can set the AUTO COMMIT ON  as a default somewhere?
    Wondering if any one has attempted this or has any insights?
    Regards,
    Mohit.
    Environment is - Crystal 2008 and Oracle 11GR2, we are using Oracle drivers (and not odbc)

    Hmmm... I don't use Oracle but the syntax looks good...
    You've already tested it and I assume that you are using the same driver in the production report as you used in the test, so that shouldn't be an issue...
    how are you pulling the data? Is the final SELECT statement that pulls the report data in the same command as the INSERT script, or is the INSERT script in it's own command?
    The reason I ask... If you are trying to pass a multi-valued parameter to a command, it won't work. If you have the insert command as it's own command while the data is being pulled with linked tables or a separate command, it is possible that the report itself will execute as expected w/o passing a value to the insert script.
    If it's all in 1 command (as it should be), a bad parameter would fail in the final SELECT causing an error.
    Also... are rows null or empty string values being added to table when the report executes? This would be an indication that the command is being executed but isn't getting the parameter value.
    Jason

  • How to insert records into the Table?

    Dear Sir,
    I'm new to JDeveloper. Now I managed to create a Frame in JDeveloper with many Text fields and a button. In the back end, I have a procedure to insert records to a table, to which I pass the values of the fields as parameters. Now I'm not getting the steps to call the PL/SQL Stored procedure when I click on the button. I'm using Oracle 9i JDeveloper version 9.0.3.1. and Oracle 9i Database.
    Please give me the complete steps to achieve my task - it is quite urgent.
    Thanking You in advance.
    Regards,
    Senthil .A. Perumal.

    The JDBC tutorial will show you how to call a stored procedure from Java:
    http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm
    One more thing, why are you using such an old version of JDeveloper? any reason not to upgrade to the 10.1.3 version of JDeveloper?
    Also you might want to look into ADF and how it makes these type of database interactions easier.
    See this demo:
    http://www.oracle.com/technology/obe/obe1013jdev/adf_swing/master_detail_page_adfswing_bc.htm

  • Insert Records into another tables

    Hi guyz,
    I have four tables as below
    1) employee
    empid (primary key)
    deptid
    emp_name
    work_location
    date_of_join
    emp_status
    date
    2) Termination
    empid reference employee
    deptid
    emp_name
    work_location
    terminate_date
    3) Resignation
    empid reference employee
    deptid
    emp_name
    work_location
    resign_date
    4) Vacation
    empid reference employee
    deptid
    emp_name
    work_location
    vac_date
    i have list item on employee form --> emp_status is list item whic contain Termination, Resignation, Vacation
    i want to update employee as well other tables if user select the respected field from the list item.
    if the user select termination/resignation from the list item the date item will be enable and user should enter the date,otherwise give the error on commit please enter the date and when user commit the record on employee it should update the table employee and delete the record belongs to Termination/Reisgnation and the record will be insert into Termination/Resignation table as select by user from list item.i tried this before but im fail i write the below code on pre-update trigger as below
    begin
    insert into termination
    (empid,deptid,emp_name,work_location,termination_date)select (empid,deptid,emp_name,work_location,date from employee where emp_status='Termination';
    delete from employee where emp_status='Termination' ;
    end;
    same as on resignation
    anybuddy help me how to do this task? to update the tables. im new in oracle.
    Regards
    Edited by: user10648713 on Dec 21, 2008 4:29 AM

    You run into the classic Mutating table problem. You cannot issue DML-statement against the same table the trigger is based on in a FOR EACH ROW-trigger.
    But even worse, you will cause any kind of client program to get in trouble if you implement such a logic. The client issues an update and as a result the record gets deleted. And, for you have a forms-module based i tell you that you will get problems with your forms-module.
    I still can't see whats the sense behind it, putting records into different tables dependant on a status. Oracle is built to manage large data volumes, so even for a large number of records that doesn't make sense to me.
    But anyway if you still want to deal with that multi-table-approach, go for the following:
    You will need three triggers on your table: a before-statement, an after-statement and a for-each-row-trigger:
    The before-statement will initialize a list of PK-Items
    The for-each-row will add the id of the processed row to the list
    The after-statement will loop over the list and process the rows.
    Create a Package for handling the logic including three procedures
    CREATE OR REPLACE PACKAGE PK_TRIGGER IS
      PROCEDURE PR_BS;
      PROCEDURE PR_ARIU(i_nEmpId IN NUMBER);
      PROCEDURE PR_AS;
    END;
    CREATE OR REPLACE PACKAGE BODY IS
      TYPE tData IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
      lData tData;
      PROCEDURE PR_BS IS
      BEGIN
        lData.DELETE;
      END;
      PROCEDURE PR_ARIU(i_nEmpId IN NUMBER) IS
        iPos PLS_INTEGER:=lData.COUNT+1;
      BEGIN
        lData(iPos):=i_nEmpId;
      END;
      PROCEDURE PR_AS IS
        CURSOR crEmp(i_nEmpId IN NUMBER) IS
          SELECT *
            FROM EMP
           WHERE EMP_ID=i_nEmpId;
        recEmp crEmp%ROWTYPE;
        iPos PLS_INTEGER;
      BEGIN
        iPos:=lData.FIRST;
        LOOP
          EXIT WHEN iPos IS NULL;
          -- Do whatever you want with the data in the record
          OPEN crEmp(lData(iPos));
          FETCH crEmp INTO recEmp;
          IF crEmp%FOUND THEN
            IF :NEW.EMP_STATUS='Termination' THEN
              DELETE FROM emp
               WHERE EMPID=lData(iPos);
              INSERT INTO TERMINATION (
                empid,
                deptid,
                emp_name,
                work_location,
                t_date
              ) VALUES (
                recEmp.empid,
                recEmp.deptid,
                recEmp.emp_name,
                recEmp.work_location,
                sysdate
            END IF;
          END IF; 
          CLOSE crEmp;
          -- Process next record
          iPos:=lIds.NEXT(iPos);
        END LOOP;
        lIds.DELETE;
      END;
    END;Now create the three triggers calling the appropiate procedures.

  • Insert records into A table in Oracle from SAP

    Hello All,
    I want to know how can we insert a record into a table which is in another server say Oracle and this needs to be done everyday.
    For example, I have a record which gives the information whether the Daily Job has run Successfully or not. Now , I have to update this information in the Oracle table.

    refer amit perfect answer.
    Re: Need to put data in oracle table from sap.

  • Problem - Inserting Records into Hashed Tables

    Help for an ABAP Newbie...
    How do I insert records into a hashed table?
    I am trying the following, but get the error message,
    *You cannot use explicit or implicit index operations with types "HASHED TABLE" or "ANY TABLE".  "LT_UNIQUE_NAME_KEYS" has the type "HASHED TABLE".
    TYPES: BEGIN OF idline,
        id TYPE i,
        END OF idline.
      DATA: lt_unique_name_keys TYPE HASHED TABLE OF idline WITH UNIQUE KEY id,
            ls_unique_name_key LIKE LINE OF lt_unique_name_keys.
    " Create a record and attempt to insert it into the internal table.
    " Why does this cause a compilation error message?
    ls_unique_name_key-id = 1.
      INSERT ls_unique_name_key INTO lt_unique_name_keys.
    Thanks,
    Walter

    INSERT ls_unique_name_key INTO TABLE lt_unique_name_keys.

  • Can not insert record into database

    Hi:
    I have problem with inserting a record into oracle database .
    can some one please give some help?
    I created a project which connected to a external database. My project is on one of the tables called family.
    I followed the steps in the example "TwoPageCrudTable" from "Technical Articles & Tips". I have 3 pages: family,
    family_create and family_update.
    In page family: I have one table which bound to family table in db.
    In page family_create, I have a bunch of text fields
    In page family_update, I also have a lot of text fields which are bound to the fields of the family table.
    In each of the page, there is a dataprovider, they all refer to the same rowset in the sessionbean.
    Here is my code of create button:
    public String create_action() {
    if ( familyDataProvider.canAppendRow() ) {
    try {             
    RowKey rowKey = familyDataProvider.appendRow();
    familyDataProvider.setCursorRow(rowKey);
    familyDataProvider.setValue("family.familyID", rowKey, fid.getText());
    // familyDataProvider.setValue("family.countryoforigin", rowKey, counOrigin.getText());
    // familyDataProvider.setValue("family.ELOD", rowKey, elod.getValue());
    // familyDataProvider.setValue("family.power", rowKey, power.getValue());
              familyDataProvider.commitChanges();
    } catch (Exception e) {
    error("Cannot append new family: " + e);
    } else {
    error("Cannot append a new row");
    return "created";
    FamilyID is the primary key of the family table which is type of String. There are also some other
    fields with String or Number. I tried to insert a new record with value in all the fields and with
    only some of the fields, neither succeeded. I also did a search in this forum and tried some of the
    suggestions, no help. So could anybody help me to find the problem? Thanks in advance.

    It keeps giving me the error:
    java.lang.IllegalArgumentException: FAMILY.FAMILYID
    Does anybody know what is the problem? Thanks!

  • Efficient Way of Inserting records into multiple tables

    Hello everyone,
    Im creating an employee application using struts framework. One of the functions of the application is to create new employees. This will involve using one web form. Upon submitting this form, a record will be inserted into two separate tables. Im using a JavaBean (Not given here) between the JSP page and the Java file (Which is partly given below). Now this Java file does work (i.e. it does insert a record into two seperate tables).
    My question is, is there a more efficient way of doing the insert into multiple tables (in terms of performance) rather than the way I've done it as shown below? Please note, I am using database pooling and MySQL db. I thought about Batch processing but was having problems writing the code for it below.
    Any help would be appreciated.
    Assad
    package com.erp.ems.db;
    import com.erp.ems.entity.Employee;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Collection;
    import java.util.ArrayList;
    public class EmployeeDAO {
         private Connection con;
         public EmployeeDAO(Connection con) {
              this.con = con;
         // METHOD FOR CREATING (INSERTING) A NEW EMPLOYEE
         public void create(Employee employee) throws CreateException {
              PreparedStatement psemployee = null;
              PreparedStatement psscheduleresource = null;
              String sqlemployee = "INSERT INTO employee (FIRSTNAME,SURNAME,GENDER) VALUES (?,?,?)";
              String sqlscheduleresource = "INSERT INTO scheduleresource (ITBCRATE,SKILLS) VALUES (?,?)";
              try {
                   if (con.isClosed()) {
                        throw new IllegalStateException("error.unexpected");
                            // Insert into employee table
                   psemployee = con.prepareStatement(sqlemployee);
                   psemployee.setString(1,employee.getFirstName());
                   psemployee.setString(2,employee.getSurname());
                   psemployee.setString(3,employee.getGender());
                            // Insert into scheduleresource table
                   psscheduleresource = con.prepareStatement(sqlscheduleresource);
                   psscheduleresource.setDouble(1,employee.getItbcRate());
                   psscheduleresource.setString(2,employee.getSkills());
                   if (psemployee.executeUpdate() != 1 && psscheduleresource.executeUpdate() != 1) {
                        throw new CreateException("error.create.employee");
              } catch (SQLException e) {
                   e.printStackTrace();
                   throw new RuntimeException("error.unexpected");
              } finally {
                   try {
                        if (psemployee != null && psscheduleresource != null)
                             psemployee.close();
                             psscheduleresource.close();
                   } catch (SQLException e) {
                        e.printStackTrace();
                        throw new RuntimeException("error.unexpected");
         }

    Hi ,
    U can use
    set Auto Commit function here ..
    let it be false first
    and when u do with u r all queries ..
    make it true
    this function take boolean values
    i e helful when u want record to be inserted in all or not at all..
    Hope it helps

  • How to insert data into database table from a servlet? Help please.

    From a servlet I want to insert a message with some servlet parameters into an oracle database table by writing 'insert into tablename'. How shall I write the sql statement?

    simple suppose u wanned to insert user name and password into table user_info then this is a simple example .....
    Best Regds
    bondzoro
    [email protected]
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class tester extends HttpServlet {
    Connection con = null;
    public void init(ServletConfig sc){
    super.int(sc);
    Class.forName("oracle.jdbc.driver.OracleDriver");
    public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOE
    try {
    con=DriverManager.getConnection("jdbc:oracle:thin:@database_URL:1521:ORA8","username","pa
    String user = req.getParameter("username");
    String pass = req.getParameter("pass");
    PreparedStatement pst = con.prepareStatement("insert into user_info values(?,?)");
    pst.setString(1,user);
    pst.setString(2,pass);
    pst.executeQuery();
    pst.close();
    con.close();
    }catch(Exception _e){
    _e.printStackTrace(System.err);
    ~

Maybe you are looking for

  • Need help sorting an ArrayList of strings by an in common substring

    I'm trying to sort a .csv file, which I read into an ArrayList as strings. I would like to sort by the IP address within the string. Can someone please help me figure out the best way to sort these strings by a common substring each has, which is an

  • Urgent Help Edit to tape!!!

    Hi I have a edit of 44 mins long , show that I have edit to tape a million times before and all the sudden it gets to a certain point on playout and stops everytime. I have open a new project , exported the show to a QT file all the same problem!!! W

  • Lollipop upgrade, mobile data doesn't work

    I upgraded to lollipop today, all fine except my mobile data doesn't work. Any ideas? Tried turning off and on, switching to airplane mode and back, and changing mobile operator and back, still not working. Thanks

  • Bought a new iPad 2 but when I click on iTunes it says it cannot connect. Please help

    The iTunes does not connect

  • Back in the days...

    Before we got this new version of this forum, when i clicked on "My Posts", below the posts i'd have a line indicating how many responses i had to my posts. I liked this feature alot, is there anyway to get it back?... If not, can you someone do some