i have done insertion of 6 field in the database..which is working good(code is below)...Now i want to do stuff that when i insert 6 field in database, then a new record also has to be insert into the database, in that new record the following changes should be done.

1)if i insert field code no ex.. 20 is inserted into the database then the a new code no 120 should be generated and inserted into database (the new code no should be started with 1, then the orginal code no will come) ex.. 10=101, 11=111, 256=1256,257=1257. The bold part is orginal record entered by the user, and the new record isnot bold.

2)Percentage field is there,ex 12%, 13% etc values will come , it calculates the percentage of credit amount field values and insert that values into the debit amount field of new record.

In my following code the code no is displayed as code, debit amount is shown as DrAmount, credit amount is shown as CrAmount, percentage field is shown as pct.


PreparedStatement pstmt = conn.prepareStatement("INSERT INTO gl_mast VALUES (?, ?, ?, ?, ?, ?)");

for (int i=1; request.getParameter((i==1)?"code""code_" +i)) != null; i++){

String Code1=request.getParameter((i==1)?"code""code_" +i));

int Code=Integer.parseInt(request.getParameter((i==1)? "code""code_" +i)));

String Description=request.getParameter((i==1)?"Descripti on""Description_" +i));

float Dr_Amt =Float.parseFloat(request.getParameter((i==1)?"DrA mount""DrAmount_" +i)));
pstmt.setFloat(3,Dr_Amt );

float Cr_Amt =Float.parseFloat(request.getParameter((i==1)?"CrA mount""CrAmount_" +i)));

String Type =request.getParameter((i==1)?"type""type_" +i));
pstmt.setString(5,Type );

float Pct =Float.parseFloat(request.getParameter((i==1)?"pct ""pct_" +i)));



plz...look at my code and solved my prob....