Contents
CREATE TRIGGER NewCats on CategoriesAFTER INSERT ASBEGINselect CategoryId,CategoryName from insertedEND
CREATE TRIGGER NewCats on Categories
AFTER INSERT AS
BEGIN
select CategoryId,CategoryName from inserted
END
CREATE TRIGGER MosFshiKat on CategoriesAFTER DELETE ASBEGINROLLBACKEND
CREATE TRIGGER MosFshiKat on Categories
AFTER DELETE AS
ROLLBACK
CREATE TRIGGER AfishoKatMod on CategoriesAFTER UPDATE ASBEGINSELECT CategoryId, CategoryName from Categories END
CREATE TRIGGER AfishoKatMod on Categories
AFTER UPDATE AS
SELECT CategoryId, CategoryName from Categories
create trigger fixed_price ON Products
Declare @oldprice as float
Declare @newprice as float
select @oldprice=unitprice from deleted
select @newprice=unitprice from inserted
if(@oldprice<>@newprice)
begin
rollback
print 'nuk mund te modifikohet cmimi'
end
if exists
(
select * from inserted i join deleted d
on i.product_id=d.product_id
where i.unitprice<>d.unitprice
)