Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Asad.

Asked: July 08, 2018 - 10:33 am UTC

Last updated: July 09, 2018 - 4:49 am UTC

Version: oracle 10g

Viewed 1000+ times

You Asked

create or replace trigger t_emp_no
before insert on emp_info
begin
insert into emp_info(emp_no)
values(s_emp_no.nextval)
end;
/
i tried to entry primary key emp_no values without showing it on oracle 10g form with S_emp_no sequence .Problem is -i can't entry other rows value without primary key value, above trigger does not work. Can i get a solution ??

and Connor said...

I'm not entirely sure what you're trying to achieve, but I'll guess that just want to populate the primary key column? In that case, just:

create or replace trigger t_emp_no
before insert on emp_info
for each row
when (new.empno is null)
begin
:new.emp_no := s_emp_no.nextval;
end;
/


The trigger does not the insert itself - it simply fires and performs an action *during* the insert

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database