Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Posts
    37

    Question Unanswered: insert statement

    i user db2 v7.2.
    in my jsp page, i get several values via request.getParameterValues() method. i have to insert these values into a table.
    my question is, how can i perform this insertion without looping through the values ?
    for (i=1; i <= parameter-count; ++i)
    st.executeUpdate("insert into table-name (fieldname) values ("+request.getParameter(i)+")");
    with this solution i have to access the database parameter-count times.

    i want to write something like this :

    st.executeUpdate("insert into table-name (fieldname) select id from dummy-table where id in ("+comma-seperated-values.toString()+")");

    this way i only had to access the database once.
    has anybody a solution ?
    thanks in advance

    Mehmet Gunacti
    mserkan@gmx.net

    ps: there's no method like getParameter(int param-number), i used it to explain my question

  2. #2
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    You can insert more than one set of values in a single statement.

    INSERT INTO YOURTABLE (COLS)
    VALUES (...), (...), (...)

  3. #3
    Join Date
    Oct 2002
    Posts
    37

    Smile insert statement

    that helped
    thanks
    Mehmet Gunacti
    mserkan@gmx.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •