Creating A Trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JKAG
    New Member
    • Jan 2007
    • 2

    Creating A Trigger

    Hallo,
    I am new on this forum but I have an urgent problem. How can I

    1. Create a trigger which has the following characteristics :
    • It should be named reorder.
    • It should fire after an update of the qty column on the stock table, if the new
    value of qty is <= 5.
    • New should be referenced as n.
    • The triggered action should insert the values n.itemno and current timestamp
    into the reorder table,
    whereby when an inventory item in the STOCK table falls below a quantity of 6, the REORDER table will have a row inserted.

    Any kind of help is very much appreciated.
  • jai80
    New Member
    • Nov 2006
    • 30

    #2
    Originally posted by JKAG
    Hallo,
    I am new on this forum but I have an urgent problem. How can I

    1. Create a trigger which has the following characteristics :
    • It should be named reorder.
    • It should fire after an update of the qty column on the stock table, if the new
    value of qty is <= 5.
    • New should be referenced as n.
    • The triggered action should insert the values n.itemno and current timestamp
    into the reorder table,
    whereby when an inventory item in the STOCK table falls below a quantity of 6, the REORDER table will have a row inserted.

    Any kind of help is very much appreciated.
    hi jkag,

    Check out the Trigger i have developed in sqlserver 2000.

    sample tables used:
    create table stock
    (
    itemid int identity(1,1) primary key,
    prdname varchar(100),
    qty int,
    )

    create table reorder
    (
    reoid int identity(1,1) primary key,
    itemid int,
    prdname varchar(100),
    qty int,
    currdate timestamp
    )

    create Trigger ReorderTrigg
    on stock
    for update
    as
    begin
    insert into reorder(itemid, prdname,qty) select itemid,prdname, qty from stock where qty<=5
    end
    go

    Go through the trigger and do let me know if it has solved ur query. If not also, pm me your problem. I shall try it. Gud Luck!

    cheers,
    jai

    Comment

    Working...