【发布时间】:2013-09-22 23:00:10
【问题描述】:
有人知道在插入、删除和更新操作后如何刷新表中的数据吗?我有一张简单的桌子:
create table EV_JOURNAL (EVENT_TO_TASK_ID NUMBER(3)
NOT NULL Check(EVENT_TO_TASK_ID>0), EVENT_TIME TIMESTAMP WITH TIME ZONE NOT NULL);
// 表创建 我找到了一些关于触发器的信息,并写了一个插入、删除和更新触发器后:
create or replace
TRIGGER AFT_INS_UPD_DEL_TRIG
AFTER Insert or Delete or Update ON EV_JOURNAL
For Each Row
DECLARE
BEGIN
INSERT INTO EV_JOURNAL(EVENT_TO_TASK_ID,EVENT_TIME)
VALUES(:NEW.EVENT_TO_TASK_ID, :NEW.EVENT_TIME);
END AFT_INS_UPD_DEL_TRIG;
但是当我尝试向表中插入一些数据时,是这样的:
Insert into ev_journal (event_time,event_to_task_id) values(systimestamp,2);
我有以下错误: SQL 错误:ORA-04091:表 EV_JOURNAL 正在变异,触发器/函数可能看不到它; ORA-04088: 执行触发器期间出错; 在这种情况下有人可以帮助我吗?我只需要刷新表格就可以了,但我不知道该怎么做。
我的 c# 应用程序中的代码,我需要使用给定表中的刷新数据:
public static List<EventTrigger> FillEventTriggerList (List<EventTrigger> list)
{
using (OracleConnection connection = new OracleConnection (connectionString))
{
connection.Open ();
string sqlText = "Select * From EV_JOURNAL";
OracleCommand command = new OracleCommand (sqlText, connection);
OracleDataReader reader = command.ExecuteReader ();
while (reader.Read ())
{
list.Add (new EventTrigger (int.Parse(reader [ "EVENT_TO_TASK_ID" ].ToString()),(DateTime)(reader [ "EVENT_TIME" ])));
}
}
return list;
}
所以,当我说从 EV_JOURNAL 中删除一些行时,在此 Select 查询之后,我得到了必须已删除的旧数据,但只有在我单击数据库中的刷新表后才会如此。
谢谢
【问题讨论】: