lundi 6 juillet 2015

use if statement in stored procedure to test

I need to test the PACK_TYPE field of a record that was just added and then insert to another table based on what was in that field. I decided to do this with a trigger. here is what I have but is not working.

`CREATE TRIGGER insert_INTO_PART_DIM ON Qubiscan FOR INSERT AS BEGIN IF PACK_TYPE = 'SELL' INSERT INTO PART_DIMENSION(PART_ID,SELL_PACK) SELECT part_id,1 FROM INSERTED

    IF PACK_TYPE = 'INNER'
    INSERT INTO PART_DIMENSION(PART_ID,INNER_PACK)
    SELECT
        PART_ID,1
        FROM INSERTED
END

END GO`

Can anyone help?

Aucun commentaire:

Enregistrer un commentaire