Trigger Woes

  • Hi,

    I may have misunderstood the concept of triggers, but the following trigger doesn't work, no errors, just doesn't work, can anyone tell me why? Also I don't seem to be able to use columns that do not exist in the table the trigger is defined on, I cannot find any real detailed info on triggers and what is and what isn't possible :o(

    CREATE TRIGGER [tr_addtotimeline] ON [paper_orders]

    FOR INSERT

    AS

    INSERT INTO timeline_events (publication_id,date)

    SELECT TOP 1 publication_id, delivery_date

    FROM inserted

    WHERE publication_id = inserted.publication_id

    ORDER BY orderitem_id DESC

    TIA,

    Phil Ewington

  • Ok first what is line for

    WHERE publication_id = inserted.publication_id

    and are you getting any records in the table? Also, describe what it is that should happen. From this you should get at least 1 record inserted.

  • quote:


    Ok first what is line for

    WHERE publication_id = inserted.publication_id

    and are you getting any records in the table? Also, describe what it is that should happen. From this you should get at least 1 record inserted.


    OK, discovered why the trigger is not creating a new record, no publication_id was being inserted in the table to begin with. Sorry

  • That's ok.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply