BUT my question is , is there
a way that we can just attached a constriant or something to the table
that will generate these unique numbers automatically instead of us creating
sequences manually???
The code can look like:
{in the stored procedure/package}
Procedure BIR
( p_pk in out number
)
is
begin
if p_pk is NULL
then
select sequence_name. nextval
into p_pk
from sys.dual;
end if;
end BIR;
and you call it in the trigger like
BIR(:new.pk)
--
The use of max(pk)+1 WILL
decrease your performance during inserts.