Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I got a trigger to update a table in SQL.

My actual need is in MS Access but I could not make it. So please help me to write the same trigger in MS Access.

Query is as follows:

Create  trigger insert_action 
on [quantity]
instead of  insert
As
begin
    declare @no int,@pro_id int,@pro_name varchar(10),@quantity int
    set @pro_id=(select pro_id from inserted);
    set @pro_name=(select pro_name from inserted);
    set @quantity=(select quantity from inserted);
    update quantity set quantity = quantity+@quantity where  pro_id=@pro_id;
    if not exists(select pro_id from quantity where pro_id=@pro_id)
        insert into quantity values(@pro_id,@pro_name,@quantity) 
end
share|improve this question
2  
I am pretty sure that MS Access does not have any triggers like SQL Server, etc. You have to implement data macros using events. See this post -- blogs.office.com/b/microsoft-access/archive/2009/08/13/… –  bluefeet Feb 6 '13 at 11:18
    
Here is a rough example from Stackoverflow stackoverflow.com/questions/14429742/… –  Remou Feb 6 '13 at 11:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.