we always face the problem of solving the primary key value inside the forms, So we have the following possible solutions
solving by this solution enables us to avoid the disadvantage raised by using sequences which is "gabs raised in sequence values" by insuring that we get the next actual value in a serial number
here we have two possible ways
in the pre-insert trigger add the following code
--
-- begin making a default value for Primary key
--
if :SPAREPARTGROUPS.GROUPID is null then
select nvl(max(GROUPID),0)+1
into :SPAREPARTGROUPS.GROUPID
from SPAREPARTGROUPS;
end if;
--
-- end making a default value for Primary key
--
in the pre-insert trigger add the following code
--
-- begin making a default value for Primary key
--
declare
idexist ALARMCODES.ALARMID%type;
begin
select ALARMID
into idexist
from ALARMCODES
where ALARMID = :ALARMCODES.ALARMID;
if idexist is not null then
select max(ALARMID)+1
into :ALARMCODES.ALARMID
from ALARMCODES;
end if;
exception
when no_data_found then
select nvl(max(ALARMID),0)+1
into :ALARMCODES.ALARMID
from ALARMCODES;
end;
--
-- end making a default value for Primary key
--