【问题标题】:Trigger inserting date as 30/05/9305 22:58触发插入日期为 30/05/9305 22:58
【发布时间】:2018-07-17 22:31:04
【问题描述】:

在我的应用程序中,我定义了一个触发器来插入一个表和一个视图,所有插入的条目都是完美的,除了日期参数,它被插入为'30/05/9305 22:58'。触发器获取的值是通过 UI 获得的,我已经检查了从 Java 代码从获取 UI 的值到将其传递给触发器的整个工作流程,一切看起来都很完美。 谁能帮我确定哪里出了问题?

选择的日期是 07/02/2018,已转换为 30/05/9305 22:58

这是用于此目的的触发器的简短快照:

create or replace trigger "TEST_TRIGGER"
instead of insert on "MY_VIEW"
referencing NEW as n
for each row
 BEGIN
 insert into DEMO_TABLE
     (id, emp_name,report_date,insert_date) 
     select 
     demo.table_seq.nextval,:n.id,:n.emp_name,:n.report_date,sysdate from dual;
END;

【问题讨论】:

  • report_date 是如何定义的? (假设问题出在report_date。)它是date 列吗?
  • select ... from dual 不需要,简单的insert into DEMO_TABLE (id, emp_name,report_date,insert_date) values (demo.table_seq.nextval,:n.emp_name,:n.report_date,sysdate)
  • @WilliamRobertson 它被定义为 TIMESTAMP...
  • 请向我们展示您的插入 SQL 语句(包括值)。
  • 嗨...当我切换到使用 Oracle Database 12c EE 时,它可以正常工作,而当我使用 Oracle Database 11g 时出现上述问题。但是这种切换是不可行的,所以试图找到根本原因。如果有人知道,请告诉我...非常感谢!

标签: oracle oracle11g triggers oracle12c


【解决方案1】:

您的插入语句可能是错误的。它在选择中有额外的列

insert into DEMO_TABLE
     (id, emp_name,report_date,insert_date) 
     select 
     :n.id,:n.emp_name,:n.report_date,sysdate from dual;

【讨论】:

    猜你喜欢
    • 2015-10-31
    • 2020-10-08
    • 1970-01-01
    • 1970-01-01
    • 2020-12-07
    • 1970-01-01
    • 2021-08-13
    • 2015-07-01
    • 2013-10-06
    相关资源
    最近更新 更多