dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

automatic increment for field - Oracle Errors

This is a discussion on automatic increment for field - Oracle Errors ; 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, ...


Home > Database Forum > Oracle Database > Oracle Errors > automatic increment for field

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 03-25-2008, 04:38 AM
Database Newbie
 
Join Date: Mar 2008
Posts: 1
mvs.priya is on a distinguished road
Default automatic increment for field

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 = db.create().prepareStatement("INSERT INTO admininsertbook(sno,bookname,author,available) VALUES (?,?,?,?) ");
for(int i=0; i< arrayList.size(); i++){

stmt.setInt(1, db.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();
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Automatic Runstats Database Administrator ibm-db2 0 01-15-2008 01:03 AM
Oracle form builder automatic increment while inserting new row Database Administrator Oracle Tools 15 05-31-2006 11:13 AM
RECOVER AUTOMATIC STANDBY DATABASE; Script question Database Administrator Database Discussions 55 03-03-2004 11:44 AM
RECOVER AUTOMATIC STANDBY DATABASE; Script question Database Administrator Oracle Server 0 02-22-2004 07:06 PM
Standby: Managed or Automatic? Database Administrator Oracle Server 15 02-20-2004 06:29 PM


All times are GMT -4. The time now is 12:10 AM.