Hiya chaps
I have a table called movements which tracks the issuing of safety wear etc.
movement_id int (identity yes)
emp_no char(8)
clothing_id int (fk)
create_dte smalldatetime
create_by_emp_n o char(8)
clothing_price decimal
I need to create a function that will check first that a user has or has not received an item (param clothing_id)
if they have not then insert a new entry.
else
If they have had an item that matches the clothing_id param - check if it is within one year (if it is then do not insert) if the user has had this item and it was longer than a year insert the item.
Ideally I would like the function to return a 1 if a new record was inserted (for the first time)
a 2 if a record was inserted(user has had this item longer than a year ago)
a 3 if user has this item within one year (no record inserted)
Dont know if this is feasable as I am new to transact sql. Thanks
I have a table called movements which tracks the issuing of safety wear etc.
movement_id int (identity yes)
emp_no char(8)
clothing_id int (fk)
create_dte smalldatetime
create_by_emp_n o char(8)
clothing_price decimal
I need to create a function that will check first that a user has or has not received an item (param clothing_id)
if they have not then insert a new entry.
else
If they have had an item that matches the clothing_id param - check if it is within one year (if it is then do not insert) if the user has had this item and it was longer than a year insert the item.
Ideally I would like the function to return a 1 if a new record was inserted (for the first time)
a 2 if a record was inserted(user has had this item longer than a year ago)
a 3 if user has this item within one year (no record inserted)
Dont know if this is feasable as I am new to transact sql. Thanks
Comment