| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
|
| hi to all i am new to this forum . i want to automatical increment for serial number in the table . i am create table ,sequence for that table and trigger for that . create table test (id number, testdata varchar2(255)); create sequence test_seq start with 1 increment by 1 nomaxvalue; create trigger test_trigger before insert on test for each row begin select test_seq.nextval into :new.id from dual; end; after creating this i am inserting values to this table from action class in struts but i am able to insert all values but i am not getting that how to insert this test_seq.nextval in the table. PreparedStatement stmt = Database.create().prepareStatement("INSERT INTO admininsertbook(sno,bookname,author,available) VALUES (?,?,?,?) "); for(int i=0; i< arrayList.size(); i++){ stmt.setInt(1, Database.getNextVal()); stmt.setString(2, (String)arrayList.get(0)); stmt.setString(3, (String)arrayList.get(1)) stmt.setString(4, (String)arrayList.get(2)) stmt.addBatch(); } stmt.executeBatch(); |
![]() |
| Thread Tools | |
| Display Modes | |