www.webdeveloper.com
Results 1 to 2 of 2

Thread: updates problem of db table

  1. #1
    Join Date
    Oct 2004
    Posts
    169

    updates problem of db table

    hi..

    i have used the following query for the update of two table values...

    colum name=1)pay_header 2)pay_detail..

    if i update the chq_amt values of pay_header table..them it also changes the db_amt values of pay_detail table.. means both column values of two different tabel should be equal.

    here vou_no is foreign key in the pay_detail table...



    PreparedStatement pstatement = conn.prepareStatement(
    "UPDATE pay_header SET chq_amt = ? WHERE pay_header.vou_no=? ");

    PreparedStatement pstatement1 = conn.prepareStatement(
    "UPDATE pay_detail SET pay_detail.db_amt = ? WHERE pay_detail.vou_no=? ");


    pstatement.setFloat(1,Float.parseFloat(request.getParameter("chq_amt")));
    pstatement1.setFloat(1,Float.parseFloat(request.getParameter("chq_amt")));
    pstatement.setString(2,request.getParameter("vou_no"));
    pstatement.setString(2,request.getParameter("vou_no"));

    int rowCount = pstatement.executeUpdate();
    int rowCount1 = pstatement.executeUpdate();
    conn.setAutoCommit(false);
    conn.setAutoCommit(true);

    its only update the one field either chq_amt or db_amt..

    plzz help me

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    You missed a character. On the last line, you missed a 1.
    Code:
    pstatement.setFloat(1,Float.parseFloat(request.getParameter("chq_amt")));
    pstatement1.setFloat(1,Float.parseFloat(request.getParameter("chq_amt")));
    pstatement.setString(2,request.getParameter("vou_no"));
    pstatement1.setString(2,request.getParameter("vou_no"));
    Regards.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles