Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TRIGGER PROBLEM

Status
Not open for further replies.

ctau

IS-IT--Management
Feb 8, 2000
34
US
I am trying to write a trigger between an inventory table and a returns table. When a return comes in I want it to check the condition field to see if the return is to be destroyed or returned to stock. If it is to be returned to stock it should add the value to Qty_on_hand and to Qty_returned in the inventory table.

This is what I am trying so far.



CREATE TRIGGER RETURNS_CALC ON [RETURNS]
FOR INSERT
AS UPDATE PM

IF ( RETURNS.CONDITION = '1')
BEGIN
SET PM.QTY_ON_HAND = (PM.QTY_ON_HAND + RETURNS.QTY)
SET PM.QTY_RETURNED = (PM.QTY_RETURNED + RETURNS.QTY)
FROM PRODUCT_MASTER PM JOIN INSERTED
ON RETURNS.PART_NUMBER = PM.PART_NUMBER)
END
 
it should read
on inserted.part_number = pm.part_number

other than that it looks ok to me.

 
It is still giving me two errors. I get Error 156 Incorrect Syntax near the keyword 'IF'. And an Error on line 7 near '.'. Line 7 is my first Set statement and if I comment out the Set statement it gives me the same error on my next Set statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top