oracle 如何将新日期条目设置为当前日期?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5038095/
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-18 22:48:24 来源:igfitidea点击:
How to set new date entries to current date?
提问by indolent
I am trying to create a trigger. It is supposed to update any new date entry to sysdate. So far, I have the following code. However, I get "invalid table name" and "SQL statement ignored" errors.
我正在尝试创建触发器。它应该将任何新的日期条目更新为 sysdate。到目前为止,我有以下代码。但是,我收到“无效的表名”和“忽略 SQL 语句”错误。
CREATE OR REPLACE TRIGGER new_orders
AFTER INSERT ON orders
FOR EACH ROW
BEGIN
IF INSERTING THEN
UPDATE
SET order_date := SYSDATE;
END IF;
END;
/
回答by zerkms
CREATE OR REPLACE TRIGGER new_orders
BEFORE INSERT ON orders
FOR EACH ROW
BEGIN
:NEW.order_date := SYSDATE;
END;
/