Oracle - 错误:'ORA-01400:无法将 NULL 插入

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15247335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:29:36  来源:igfitidea点击:

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

mysqloraclemigrationnotnullora-01400

提问by neoerol

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

我正在尝试向表中插入一条记录,但出现错误 -

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

'ORA-01400: cannot insert NULL into (....'. 表结构是:

I migrate from Mysql to Oracle.

我从 Mysql 迁移到 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

在 Mysql 上这有效,但在 Oracle 上它不起作用。我怎样才能解决这个问题?我是否需要编写所有列插入查询或取消选择非空选项

回答by user3546225

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;