create table test (id numeric, t date not null);
create trigger test_in
before insert on test
for each row
when New.t is null
begin
-- set New.t = now();
end;
集New.t沒有工作,where can be only select/insert/update/delete stmt. 我不能更改數據庫結構(可以設置默認值)。 由於「非空」限制,插入觸發器也不適合。 我發現的唯一的解決辦法:用於說明目的
insert into test values (New.id, now());
select raise(ignore);
測試數據庫而已,在實踐中也有更復雜的情況下計算得到的數據。有可能是這樣的「更新新集New.t =現在()」,或不?
你可以創建一個視圖與INSTEAD OF觸發器,並插入到視圖? – 2012-02-20 06:42:02
這也是一個決定的變體,但不能解決問題。在我的情況下,表是在同步過程中創建的。之後我可以運行任何ddl。 – lunicon 2012-02-20 07:08:34
在主數據庫模型中也使用set stmt觸發器。我可以創建視圖,但必須更改和編程(如果我可以...) – lunicon 2012-02-20 07:16:51