SQL>
SQL> create table foo(
2 id number primary key,
3 data varchar2(100) );
Table created.
SQL>
SQL> create sequence foo_seq;
Sequence created.
SQL>
SQL> create or replace trigger myTrigger
2 before insert
3 on foo
4 for each row
5 begin
6 select foo_seq.nextval
7 into :new.id
8 from dual;
9 end;
10 /
Trigger created.
SQL>
SQL> insert into foo ( data ) values ( 'Christopher' );
1 row created.
SQL>
SQL> insert into foo ( id, data )values ( 5, 'Sean' );
1 row created.
SQL>
SQL> select * from foo;
ID DATA
---------- ----------------------------------------------------------------------------------------------------
1 Christopher
2 Sean
SQL>
SQL> drop table foo;
Table dropped.
SQL> drop sequence foo_seq;
Sequence dropped.
SQL>
SQL>
|