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
Oracle - Error: 'ORA-01400: cannot insert NULL into
提问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;