Oracle - Error: 'ORA-01400: cannot insert NULL into

neoerol picture neoerol · Mar 6, 2013 · Viewed 14.2k times · Source

I'm trying to insert a record into a table, but getting the error -

'ORA-01400: cannot insert NULL into (....'. The table structure is:

I migrate from Mysql to Oracle.

On Mysql this works, but on Oracle it is not working. How can I fix this? Do I need write all column insert query or unselect not null option

Answer

user3546225 picture user3546225 · Apr 17, 2014

Try this:

create or replace trigger EDITIONS_COR
  before insert or update on EDITIONS
  for each row
begin
  if INSERTING then
    select EDITIONS_SEQ.nextval into :new.ID from DUAL;
  end if;
  :new.CORDATE:=SYSDATE;
  :new.USERNAME:=USER;
end;