Insert statement stores multiple records...

Hi there. ive been having trouble with my insert statements. for some reason unknown to me, the following code creates two entries in the same table:
SELECT product_id_sequence.nextval
into products.prod_id
from dual;
INSERT INTO PRODUCTS VALUES('PRD'|| :products.prod_id,:products.prod_status, :products.store_id);
INSERT INTO PRODUCT_PHONE VALUES('PRD' || :products.prod_id, :PHONE.phone_model, :phone.phone_price, :phone.phone_brand,
:phone.phone_description);
commit;
The result of the sql statement:
TABLE PRODUCTS
PRD10000119 | In Stock | STR100000005
10000119 | In Stock | STR100000005
As you can see, the first 3 letters of the product_id are not repeated in the second record. The same is also repeated in the product_phone table. i am not sure why this is the case. please help
Message was edited by:
user597970

Hi,
Do you have the two products and product_phone blocks on your form ?
are the database blocks matching tables in your db?
could explain how you built the form?
I think that your form has two database blocks, which will perform DML actions as this is a built in funcionality in forms.
From your code, the inserts are performed ok, and the commit after, commits the data on screen as well, hence the second entry.
Please take alook at this thread, for suggestions on forum usage:
http://forums.oracle.com/forums/ann.jspa?annID=432
Regards,
Hugo

Similar Messages

  • Problem in UPDATE statement In Multiple Record Block

    Hi Friends,
    I have problem in update Statement for updating the record in multiple record data Block.
    I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
    I am inserting the fields like category,and post_no for partiular job in single data block
    Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
    There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
    then its updating all the record.
    my code is Bellow,
    IF v_count 0 THEN
    LOOP
    IF :SYSTEM.last_record 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
    :POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    next_record;
    ELSIF :SYSTEM.last_record = 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
    :POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    EXIT;
    END IF;
    END LOOP;
    SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
    v_button_no := SHOW_ALERT('user_alert');
    FORMS_DDL('COMMIT');
    CLEAR_FORM(no_validate);
    Please Guide me
    Thanks in advence

    As you do a loop over all the records in the block, of course every record is updated.
    Also, what you do is not the way is intended to be used. In general, you base a block on a table,then there is no need at all for writing INSERT's or UPDATE's. Forms also know's then, which records to be updated and which not.

  • Problem In Update Statement In Multiple Record Data Block

    Hi Friends,
    I have problem in update Statement for updating the record in multiple record data Block.
    I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
    I am inserting the fields like category,and post_no for partiular job in single data block
    Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
    There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
    then its updating all the record.
    my code is Bellow,
    IF v_count <> 0 THEN
    LOOP
    IF :SYSTEM.last_record <> 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
    :POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    next_record;
    ELSIF :SYSTEM.last_record = 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
         VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
              :POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    EXIT;
    END IF;
    END LOOP;
    SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
    v_button_no := SHOW_ALERT('user_alert');
    FORMS_DDL('COMMIT');
    CLEAR_FORM(no_validate);
    Please Guide me
    Thanks in advence

    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;These update statements are without where clause, so it will update all records.
    If it is specific to oracle forms then u may get better help at Forms section.

  • How to store multiple records for one master reocrd using sequnce

    dear,
    my question is in one form i have master block f and detail block.
    my question is i created one sequence and assign to master table. but i dont know how to assign that sequence to multiple record in detail table for that particular master record. i got lots of answer previously but i m not getting exactly.pls tell me full procedure otherwise gv me one demo application
    NOTe: the sequnce is created after master record commiting to database.
    PLS pls help me
    Thanks
    damby

    i did not get answer pls help me.

  • Use of LIKE in where clause of select statement for multiple records

    Hi Experts,
    I have a account number field which is uploaded from a file. Now this account numbers uploaded does not match fully with sap table account numbers but it contains all of the numbers provided in the file mostly in the upright positions.
    For example in file we have account number as 2ARS1 while in sap table the value is 002ARS1.
    And i want to fetch data from sap table based on account number uploaded. So, i am trying to use LIKE with for all entries but its not working as mentioned below but LIKE is not working with FOR ALL ENTRIES.
    data : begin of t_dda occurs 0,
            dda(19) type c,
           end of t_dda.
    data : begin of t_bukrs occurs 0,
            bukrs type t012k-bukrs,
           end of t_bukrs.
    data : dda type t012k-bankn,
           w_dda type t012k-bankn.
    CONCATENATE '%'
                             '2ARS1'
                     INTO  W_DDA.
    MOVE W_DDA TO T_DDA-DDA.
    APPEND T_DDA.
    CLEAR T_DDA.
    free t_bukrs.
    SELECT BUKRS
      FROM T012K
      into TABLE t_bukrs
        for all entries in t_dda
    WHERE BANKN like t_dda-dda.
    Can anybody suggest what should i use to get the data for multiple account numbers using one select statement only instead on using SELECT UP TO 1 ROWS in LOOP....ENDLOOP ?
    Thanks in advance,
    Akash

    Hi,
    yes, For All entries won't work for LIKE with '%  '.
    I think the other alternative is go for Native SQL by writing sub-query
    sample code is here:
    data: begin of i_mara occurs 0,
              matnr like mara-matnr,
              matkl like mara-matkl,
           end of i_mara.
    exec sql.
    select matnr, matkl from mara where matnr in (select matnr from marc) and matnr like '%ma' into :i_mara
    endexec.
    loop at i_mara.
    write:/ i_mara-matnr, i_mara-matkl.
    endloop.
    hope u got it.
    regards
    Mahesh
    Edited by: Mahesh Reddy on Jan 21, 2009 2:32 PM

  • Update statement for multiple records

    i have table a and table b
    common col in both the tables is emp_id
    in table b i have district_id
    which i want to update in table a.... column district_id for all the employees
    how to write update statement for this
    Edited by: user10873676 on Oct 17, 2011 8:00 AM

    Based on your current description, we have something like this...
    SQL> create table a (emp_id number)
      2  /
    Table created.
    SQL>
    SQL> create table b (emp_id number, district_id number)
      2  /
    Table created.
    SQL>
    SQL> insert into a (emp_id)
      2  select rownum from dual connect by rownum <= 10
      3  /
    10 rows created.
    SQL>
    SQL> insert into b (emp_id, district_id)
      2  select rownum, 10-rownum from dual connect by rownum <= 10
      3  /
    10 rows created.
    SQL>
    SQL> update b
      2  set district_id = 1
      3  /
    10 rows updated.
    SQL>
    SQL> select * from a;
        EMP_ID
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.
    SQL> select * from b;
        EMP_ID DISTRICT_ID
             1           1
             2           1
             3           1
             4           1
             5           1
             6           1
             7           1
             8           1
             9           1
            10           1
    10 rows selected.Which I'm sure is NOT what you want as the update on table b has nothing to do with table a, and we have no idea what the district_id should be updated with.

  • Insert Multiple Records into Multiple ZTABLEs inside the BAPI

    Hi,
    I have a requirement to Insert or Update Multiple Records into a ZTABLE inside the BAPI. Is there any special approach inside the BAPI to insert or update ZTABLEs with multiple records. It looks like the simple INSERT Statement is not working. Can you please suggest me a Suitable solution for this req?
    Thanks and Regards,
    Kannan

    Hi,
    INSERT ZTABLE FROM TABLE ITAB.
    The itab structure should be of the structure ZTABLE..
      Same for MODIFY and update.
      MODIFY ZTABLE FROM TABLE ITAB..
    Thanks,
    Naren

  • How to execute multiple records in table control

    HI.
    I have a requirement that in table control user will select more than one row and when he clicks 'SAVE' it should go and sit in a custom table. how to pass more than one records.
    thanks & regards.
    sandeep

    Hi Sandeep,
    I understand your requirement .......
    See this standard program........
    <b>" DEMO_DYNPRO_TABCONT_LOOP_AT "</b>
    <b>Understand how DELETE button is working,inorder to delete multiple lines....Copy this program if necessary..OK.
    Simply,Replace DELETE statement with your INSERT statement to push records into your custom table....very easily you can do it.</b>
    <b>Reward all helpful answers.</b><b>
    Hope you problem is solved.</b>
    Regards,
    V.Raghavender.

  • Insert multiple records into a table(Oracle 9i) from a single PHP statement

    How can I insert multiple records into a table(Oracle 9i) from a single PHP statement?
    From what all I've found, the statement below would work if I were using MySQL:
         insert into scen
         (indx,share,expire,pitch,curve,surface,call)
         values
         (81202, 28, 171, .27, 0, 0, 'C' ),
         (81204, 28, 501, .25, 0, 0, 'C' ),
         (81203, 17, 35, .222, 0, 0, 'C' ),
         (81202, 28, 171, .27, 2, 0, 'C' ),
         (81204, 28, 501, .20, 0, 1, 'C' ),
         (81203, 28, 135, .22, 1, 0, 'C' )
    The amount of records varies into the multiple-dozens. My aim is to utilize the power of Oracle while avoiding the i/o of dozens of single-record inserts.
    Thank you,
    Will

    You could look at the INSERT ALL statement found in the documentation here:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_913a.htm#2133161
    My personal opinion is that you probably won't see any benefit because under the hood I think Oracle will still be doing single row inserts. I could be wrong though.
    The only way to confirm was if you did a test of multiple inserts vs an INSERT ALL, that is if the INSERT ALL met your requirements.
    HTH.

  • Problem for Struts action to insert multiple records

    I am writting a code for Struts action which inserting a single record to table A and multiple records to table B .The architecture that I applied is Struts+Spring+iBatis.The multiple records are come from a 10-rows table in the design.The name of each column element is same.The field name other than these are just single-row field.
    <tr>
    <td><input name="date" type="text" size="12" /></td>
    <td><input name="billno" type="text" size="8" /></td>
    <td><input name="desc" type="text" size="11" /></td>
    <td><input name="purpose" type="text" size="20" /></td>
    <td><input name="proName" type="text" size="6" /></td>
    <td><input name="trainingCost" type="text" size="5" /></td>
    <td><input name="travelCost" type="text" size="7" /></td>
    <td><input name="entCost"  type="text" size="5" /></td>
    <td><input name="miscCost" type="text" size="5" /></td>
    </tr> I am using three DTO objects to hold the data.claimArray is the ClaimDTO array that hold the multiple record insert to table B.claimdto is the object that hold the single field record to table A.claim_dtldto is the object that hold the single field record to table B.
    PK of table A and table B are claimNo and claimDtlNo respectively.claimNo is also FK of table B. HTMLUtil is just an API that I used it for type conversion.There will have two insert statements in iBatis xml, insertClaim & insertClaimDtl to insert data into table A and table B respectively.I not sure what went wrong in the code,the data is not inserted into db.Thank advanced for you guys help..
    This is the codes in Action file:
    public class InsertClaimAction extends SpringAction {
       public ActionForward execute(ActionMapping mapping,
                                     ActionForm form,
                                     HttpServletRequest request,
                                     HttpServletResponse response) throws Exception {
        // string arrays that store multiple values
        String [] date = new String[10];
        String [] billno = new String[10];
        String [] description = new String[10];
        String [] purpose = new String[10];
        String [] proName = new String[10];
        String [] trainingCost = new String[10];
        String [] travelCost = new String[10];
        String [] entCost = new String[10];
        String [] miscCost = new String[10];
        String staffName = request.getParameter("name");
        String claimMy = request.getParameter("monthyear");
        String department = request.getParameter("department");
        String designation = request.getParameter("designation");
        Double excrate =  HTMLUtil.str2double(request.getParameter("excrate"),0.0);
        Double grandTotal = HTMLUtil.str2double(request.getParameter("grandTotal"),0.0);
        Double totalRM = HTMLUtil.str2double(request.getParameter("totalRM"),0.0);
        Double totalFC =    HTMLUtil.str2double(request.getParameter("totalFC"),0.0);
        String fcName = request.getParameter("fcAbbr");
        if(request.getParameter("date") != null)
            date = request.getParameterValues("date");
        if(request.getParameter("billno") != null)
            billno = request.getParameterValues("billno");
        if(request.getParameter("description") != null)
            description = request.getParameterValues("description");
        if(request.getParameter("purpose") != null)
            purpose = request.getParameterValues("purpose");
        if(request.getParameter("proName") != null)
            proName = request.getParameterValues("proName");
        if(request.getParameter("trainingCost") != null)
            trainingCost = request.getParameterValues("trainingCost");
        if(request.getParameter("travelCost") != null)
            travelCost = request.getParameterValues("travelCost");
        if(request.getParameter("entCost") != null)
            entCost = request.getParameterValues("entCost");
        if(request.getParameter("miscCost") != null)
            miscCost = request.getParameterValues("miscCost");
          //initialize dto
        ClaimDTO claimdto = new ClaimDTO();
        ClaimDTO claim_dtldto = new ClaimDTO();
        ClaimDTO[] claimArray = new ClaimDTO[10];
        claimdto.setClaimNo(claimNo);
        claimdto.setStaffName(staffName);
        claimdto.setClaimMy(claimMy);
        claimdto.setDepartment(department);
        claimdto.setDesignation(designation);
        claimdto.setExcrate(excrate);
        claimdto.setGrandTotal(grandTotal);
        claim_dtldto.setClaimDtlNo(claimDtlNo);
        claim_dtldto.setClaimNo(claimNo);
        claim_dtldto.setTotalRM(totalRM);
        claim_dtldto.setTotalFC(totalFC);
        claim_dtldto.setFcName(fcName);
        for(int i = 0;i < claimArray.length;i++) {
            if(claimArray[i] != null) {
                claimArray.setDate(date[i]);
    claimArray[i].setBillno(billno[i]);
    claimArray[i].setDescription(description[i]);
    claimArray[i].setPurpose(purpose[i]);
    claimArray[i].setProName(proName[i]);
    claimArray[i].setTrainingCost(Double.parseDouble(trainingCost[i]));
    claimArray[i].setTravelCost(Double.parseDouble(travelCost[i]));
    claimArray[i].setEntCost(Double.parseDouble(entCost[i]));
    claimArray[i].setMiscCost(Double.parseDouble(miscCost[i]));
    //service
    ClaimService springservice = (ClaimService)getBean("ClaimService");
    springservice.insertClaim(claimdto);
    springservice.insertClaimDtl(claim_dtldto,claimArray);
    return mapping.findForward("success");

    Two things; you need to pass #number# as a form field and you
    need to pull the correct record out.
    Use this:
    <cfloop list="#form.fieldnames#" index="fieldName">
    <CFSET record = Evaluate("form.record_#number#")>
    </cfloop>
    Here's some example code:

  • Report with stored proc running multiple stored procedures with insert statement

    Hi,
    I wonder if this is possible in SSRS ... I use the 2012 version (Data Tools).
    I have a report that triggers a stored procedure. See below.
    Within this SP there are 2 insert statements getting data from 2 other SP's.
    When I make a dataset referring to the main SP below, SSRS does not show me any fields at all.
    Is this because it's a SP with insert statements and nested SP's?
    At the end of the SP I make a select so it should see all the fields.
    The parameters @month and @costcenter are multivalue params. I use a special function to convert the multivalues, selected in the report, into a string to pass it correctly to the query (comma separated).
    USE [TestDB]
    GO
    /****** Object:  StoredProcedure [dbo].[_Pink_SP_StandingsRegisterDataset]    Script Date: 15-4-2014 13:31:30 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[_Pink_SP_StandingsRegisterDataset]
    @year INT,
    @month NVARCHAR(50),
    @costcenter NVARCHAR(500),
    @GLaccount NVARCHAR(9)
    AS
    BEGIN
    /* Remove existing content*/
    DELETE FROM _Pink_TB_StandingsRegister
    /* Add records part 1 */
    INSERT INTO _Pink_TB_StandingsRegister
    EXEC _Pink_SP_StandingsRegister @year, @month, @costcenter, @GLaccount
    /* Add records part 2 */
    INSERT INTO _Pink_TB_StandingsRegister
    Type,
    Row,
    Year,
    Month,
    YearDatetable,
    MonthDatetable
    EXEC _Pink_SP_StandingsRegisterDatetable @year
    /* Select all records */
    SELECT *
    FROM _Pink_TB_StandingsRegister
    END
    GO

    Hi bijntjede2e,
    After testing a similar scenario in my own environment, it works well in Reporting Services. In my test, the stored procedure returns all the fields from _Pink_TB_StandingsRegister table in the dataset. Then I select some values from year, month, costcenter
    and Glaccount parameters, it inserts some values in the _Pink_TB_StandingsRegister table. So we can use this stored procedure as the dataset in the report.
    In order to solve the problem more efficiently, I need to clarify some information.
    Are you pass multiple values parameter to one stored procedure correctly? We can refer to the following thread:
    http://social.technet.microsoft.com/Forums/en-US/dbdfa101-cccc-4e9f-aa50-566dc5ebcc27/ssrs-2008-r2-report-dataset-call-a-stored-procedure?forum=sqlrep
    What results are you get when executing the stored procedure in SQL Server Management Studio? Is it works well? We should double those stored procedures.
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Insert multiple records help

    Hello all! I have implemented a simple shoppingcart (not for commercial purposes) and I would like to help me with the following code. When a user makes shopping, the items appear in a table with the use of a java servlet with arraylist.. When the user checkouts, I want to call a servlet that it will enter the items of shoppingcart (multiple records) in a table in my db (I use mysql). I have tried to write the following code but it doesn't work. Can you give me some hints how to achieve this?
    Sorry for my possible error codes but I m new in programming and I m trying to find the way..
    Thanx a lot for your help,
    danny
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.ArrayList;
    public class Checkout extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    String[] itemsSelected;
    String[] priceSelected;
    String[] quantitySelected;
    itemsSelected = req.getParameterValues("productname");
    priceSelected = req.getParameterValues("price");
    quantitySelected = req.getParameterValues("quantity");
    // connecting to database
    Connection con = null;
    Statement stmt = null;
    PreparedStatement ps = null;
    try {
         //db connection
    String sql;
    sql = "INSERT INTO order (productname, price, quantity) VALUES (?,?,?)";
    ps = con.prepareStatement(sql);
    stmt = con.createStatement();
    for (int i = 0; i < itemsSelected.length; i++) {
    =
      ps.setString(1, itemsSelected[ i ]);
      ps.setString(2, priceSelected[ i ]);
      ps.setString(3, quantitySelected[ i ]);
           ps.executeUpdate();
       } catch (SQLException e) {
          throw new ServletException(e);
       } catch (ClassNotFoundException e) {
        throw new ServletException(e);
         } finally {
         try {
              if(stmt != null)
              stmt.close();
              if(ps != null)
              ps.close();
              if(con != null)
              con.close();
              } catch (SQLException e) {}
              out.close();
    }Message was edited by:
    danny44

    Well, after some tests I did, I understood that the variables have not be passed from the shoppingcart servlet to checkout. I declared the variables for 1 product (+productname+) ,not the array, as[b] hidden values in the shoppingcart servlet and when user clicked checkout button, checkout servlet was called and my db was updated succesfully. My problem is now, how all the products in the shopping cart can be successfully entered in the db because I receive only the last one product everytime I checkout. I think that I will probably have to declare the whole array of products and not the one string in my hidden values but I dont know how..
    If you have a solution to this, please help me.. I m new in java and I have read a lot to create my code and build my project so every help will be valuable for me to continue...
    Thanx again

  • Edit / Insert Multiple Records

    OK, I'm a Rank beginner here. I have seen the MX Kollection many years ago when I used Dreamweaver MX. I have just purchased the Dreamweaver developer's toolkit in my attempt to try and make editing multiple records in a database dreamweaver friendly.
    But I just cannot se how you make the tables that are shown in all of the tutorials that are displayed on the web! They tend to just skip past all of that and rant about how good this product is.
    Can anybody show me a page or site that will take me through how to set up and build some pages that will allow me to edit multiple records.
    Puhhhleeeaaassseee!!!

    You could look at the INSERT ALL statement found in the documentation here:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_913a.htm#2133161
    My personal opinion is that you probably won't see any benefit because under the hood I think Oracle will still be doing single row inserts. I could be wrong though.
    The only way to confirm was if you did a test of multiple inserts vs an INSERT ALL, that is if the INSERT ALL met your requirements.
    HTH.

  • Insert multiple records into database through internal table

    Hi
      please help me how to insert multiple records into database through internal table

    Hi,
    Welcome to SCN.
    Press F1 on INSERT statement and you will teh syntax as well the docu for the same.

  • Need to update multiple records using store procedure

    Hi i am trying to update multiple records using store procedure but failed to achieve pls help me with this
    for example my source is
    emp_name sal
    abhi 2000
    arti 1500
    priya 1700
    i want to increase salary of emp whose salary is less than 2000 it means rest two salary should get update..using stored procedure only
    i have tried following code
    create or replace procedure upt_sal(p_sal out emp.sal%type, p_cursor out sys_refcursor)
    is
    begin
    open p_cursor for
    select sal into p_sal from emp;
    if sal<2000 then
    update emp set sal= sal+200;
    end i;f
    end;
    and i have called the procedure using following codes
    set serveroutput on
    declare
    p_sal emp.sal%type;
    v_cursor sys_refcursor;
    begin
    upt_sal(p_sal,v_cursor);
    fetch v_cursor into p_sal;
    dbms_output.put_line(p_sal);
    end;
    the program is executing but i should get o/p like this after updating
    1700
    1900
    but i am getting first row only
    2000
    and record is not upsating...please help me with this
    thanks

    Hi Alberto,
    thanx for your valuable suggestion. but still i have doubt. the code which i have mentioned above might be simple but what if i have big requirement where i need update the data by using loops and conditional statement.
    and i have similar kind of requirement where i need to deal with procedure which returns more than one row
    my source is
    empno ename salary
    111,abhi,300
    112,arti,200
    111,naveen,600
    here i need to write a store procedure which accepts the empno (111) as input para and display ename and salary
    here i have written store procedure like this
    create or replace procedure show_emp_det(p_empno in emp.empno%type, p_ename out emp.ename%type,p_salary out emp.salary%type, p_cursor out sys_refcursor)
    is
    begin
    open p_cursor for
    select ename,salary into p_ename,p_salary from emp where empno=p_empno;
    end;
    and i have called this by using
    declare
    p_salary emp.salary%type;
    p_ename emp.ename%type
    v_cursor sys_refcursor;
    begin
    show_emp_det(111,p_ename,p_salary,v_cursor);
    fetch v_cursor into p_ename,p_salary;
    dbms_output.put_line(p_ename);
    dbms_output.put_line(p_salary);
    end;
    here i should get
    abhi,300
    naveen,600
    but i am getting first row only
    abhi,300
    but i want to fetch both rows...pls help me to find the solution

Maybe you are looking for

  • Bluetooth audio not in sync with video on iPad 2 with iOS 6

    I noticed that after I upgraded my iPad 2 to iOS 6, there was a problem with I use my A2DP Bluetooth headset (Jabra Halo) with my iPad 2. The audio is no longer in sync with the video playback! And it's really annoying. This problem does not exist wh

  • Application Object

    Is it possible to put an Object like a vector or anoter collection in an application? Something similar to session object (or application.getiniParameter("") but I don't want to recover just a String). Session.putValue("testmyobject", myvector) thank

  • DW CS4 can't see CFCs in site

    Dreamweaver CS4, with ColdFusion 8 extensions installed and Dreamweaver sites defined, refuses to see CFCs in sites defined in Dreamweaver on my localhost testing server.  The Components Panel says "There are no CFCs defined in the current site", eve

  • Why can't I see the Lightroom Presets in the Develp Module without having an image open?

    Why can't I see the Lightroom Presets in the Develp Module without having an image open?

  • K1 won't connect to Internet

    My K1 keeps scanning but won't connect.