[Zope-DB] Question about autoincrement in oracle
Santoshi Reddy
sreddy@cise.ufl.edu
Sat, 1 Mar 2003 16:52:05 -0500 (EST)
Oracle does not have an auto_increment functionality.however theres a
solution using sequences and triggers which is as follows.
1. Let's say we have a table called "test" with two columns, id and
testdata. (This is just a dumb quick example, so I won't bother to
specify any constraints on id.)
create table test (id number, testdata varchar2(255));
2. Next we'll create a sequence to use for the id numbers in our test
table.
create sequence test_seq
start with 1
increment by 1
nomaxvalue;
3. Now we're ready to create the trigger that will automatically
insert the next number from the sequence into the id column.
create trigger test_trigger
before insert on test
for each row
begin
select test_seq.nextval into :new.id from dual;
end;
/
However when we try to do run an insert query from zope,it doesnt do
the autoincrement on its own.has anyone encountered this problem.we
have to do it manually.
Thanks,
S