Subject | trigger question |
---|---|
Author | Richard Drent |
Post date | 2003-12-15T14:53:29Z |
Hi to all,...
Im using this trigger, but I would like a change in it...
If he is doing the update instead of the insert I would like that he DON'T
insert the initial insert statement that triggerd this trigger before
insert.
AS
BEGIN
if (EXISTS ( SELECT * FROM lensgroupsales
WHERE optician_ID = new.optician_ID
AND lensmaterialgroup_id = new.lensmaterialgroup_id
AND lenstypegroup_id = new.lenstypegroup_id
AND sales_date = new.sales_date)) then
begin
update lensgroupsales SET amount_sales = amount_sales +
new.amount_sales, qty_sales = qty_sales + new.qty_sales
WHERE optician_ID = new.optician_ID
AND lensmaterialgroup_id =
new.lensmaterialgroup_id
AND lenstypegroup_id = new.lenstypegroup_id
AND sales_date = new.sales_date;
end
END
Hopping that my question is clear,....thnx
Greetz
Richard Drent
Im using this trigger, but I would like a change in it...
If he is doing the update instead of the insert I would like that he DON'T
insert the initial insert statement that triggerd this trigger before
insert.
AS
BEGIN
if (EXISTS ( SELECT * FROM lensgroupsales
WHERE optician_ID = new.optician_ID
AND lensmaterialgroup_id = new.lensmaterialgroup_id
AND lenstypegroup_id = new.lenstypegroup_id
AND sales_date = new.sales_date)) then
begin
update lensgroupsales SET amount_sales = amount_sales +
new.amount_sales, qty_sales = qty_sales + new.qty_sales
WHERE optician_ID = new.optician_ID
AND lensmaterialgroup_id =
new.lensmaterialgroup_id
AND lenstypegroup_id = new.lenstypegroup_id
AND sales_date = new.sales_date;
end
END
Hopping that my question is clear,....thnx
Greetz
Richard Drent