English 中文(简体)
creation of trigger
原标题:
  • 时间:2009-11-13 15:31:40
  •  标签:
  • triggers

I have this trigger

procedure CASE_A  
as  
UPDATE table1 SET field1 = (SELECT bus FROM view1 WHERE table1.document = view1.document)  
end;

the below trigger is supposed to execute the above procedure CASE_A (Case_A is supposed to put a value into field1)

CREATE OR REPLACE TRIGGER "CASE_A" AFTER INSERT ON "TABLE1" FOR EACH ROW  
BEGIN  
CASE_A;
END;

but, it s not doing that.

最佳回答

you are doing it wrong, at least assuming this is Oracle.

better do it like this:

CREATE OR REPLACE TRIGGER "CASE_A" BEFORE INSERT ON "TABLE1" FOR EACH ROW  
BEGIN  
    SELECT bus INTO :new.field1 FROM view1 WHERE :new.document = view1.document;
END;

EDIT: since view1 depends on table1, we need to do a bit more... (read comments for more information)

CREATE OR REPLACE TRIGGER "CASE_A" BEFORE INSERT ON "TABLE1" FOR EACH ROW  
BEGIN  
    SELECT sum(FUNCTION_CASEA(b.DUE, b.RETD)) INTO :new.field1
      FROM table2
      WHERE table1.document = table2.document 
        AND table1.field1 = table2.branch;
END;
问题回答

暂无回答




相关问题
Using Aggregate Functions Inside a Trigger In MySQL

I have a People table with several attributes including age . Each time I insert a new tuple into this table, I would like to find out the average age of all the people listed in the table. If the ...

Mysql trigger/events vs Cronjob

I have an auction website which let my users place an unlimited amount of autobiddings. To monitor these autobiddings something has to check the database every second. My question is if it is ...

creation of trigger

I have this trigger procedure CASE_A as UPDATE table1 SET field1 = (SELECT bus FROM view1 WHERE table1.document = view1.document) end; the below trigger is supposed to execute the above ...

Inserting trigger (SQL 2005)

I have a temp table (question_desc, ans1, ans2, ans3, ans4, correct_ans, marks) with say 10 entries. From this table I have to insert values in two other tables: questions (q_id(auto-generated), ...

Before trigger in SQL Server

I have 2 tables: survey (id(PK), name) and survey_to_topic (survey_id(PK,FK,not null), topic_id(PK,FK,not null)). When I try to delete from survey table, I get exception: "The DELETE statement ...

Jquery mouseover/mouseout triggering inconsistently

I have two sortable lists, one being nested, with a mouse over effect on the li elements of the nested sortable list. My problem is that the mouseover and mouseout functions are being called ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签