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

断了今生、忘了曾经 提交于 2019-12-07 21:20:02

问题


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


回答1:


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;


来源:https://stackoverflow.com/questions/15247335/oracle-error-ora-01400-cannot-insert-null-into

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!