Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Error: 'ORA-01400: cannot insert NULL into ('
Eric de Redelijkheid wrote:
> Anno Domini 21-1-2006 4:30, Mladen Gogala sprak aldus:
> > On Fri, 20 Jan 2006 16:26:20 -0800, srhari wrote:
> >
> >
> >> I'm trying to insert a record into a table, but getting the error -
> >> 'ORA-01400: cannot insert NULL into (....'. The table structure is:
> >>
> >> recnum number primary key,
> >> ap# varchar2,
> >> program varchar2
> >>
> >
> > create sequence tblname_seq start with 1 nomaxvalue nocycle cache 256;
> >
> > create or replace trigger tbl_populate_pk
> > before insert on <table name>
> > for each row
> > begin
> > select tblname_seq.nextval
> > into :new.recnum
> > from dual;
> > end;
> > /
> >
> >
> insert into history values (tblname_seq.nextval, 'something','anything')
>
> no need for triggers
You obviously did not read the original post, especially this portion:
"I know that i have to supply value for primary key as well, but I want to have functionality something like IDENITITY in SQL Server where I never pass value to primary key and let the database to supply it's own."
That *does* require a trigger. The response by Mladen is, therefore, correct, as is my response providing the same advice.
David Fitzjarrell Received on Sat Jan 21 2006 - 16:51:08 CST
![]() |
![]() |