Trigger Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patelaashish
    New Member
    • Oct 2006
    • 26

    Trigger Help

    Hi,

    I am using the following trigger but it seems to do the second update and not the first update.


    CREATE TRIGGER [PREPSTATUSCOMPL ETE] ON [dbo].[PrepLog]
    FOR UPDATE
    AS
    IF EXISTS(SELECT FINISHTIME FROM PREPLOG WHERE FINISHTIME = '---')
    UPDATE RMJOB
    SET PSTATUS = 'PREPPING' FROM RMJOB,PREPLOG WHERE PREPLOG.FINISHT IME = '---'
    AND RMJOB.RMJOBID = PREPLOG.RMJOBID

    IF EXISTS(SELECT FINISHTIME FROM PREPLOG WHERE FINISHTIME != '---')
    UPDATE RMJOB
    SET PSTATUS = 'PREPPING COMPLETE' FROM RMJOB,PREPLOG WHERE PREPLOG.FINISHT IME != '---'
    AND RMJOB.RMJOBID = PREPLOG.RMJOBID


    The statement in bold is first update which does not get triggered but the second update gets triggered as soon as the if condition is meant.

    Can somebody please help me on this?

    Aash.
Working...