Reputation: 1
I am trying to update a price from table based on a condition(barcode of product), but I am having problem to update prices of products for a period of time. For example I update price(0.45-> 0.43) of product(2233-Coca Cola 0.33 ml), but i want this update to be available for a period of time (for example from date 23 until date 28) and after this date , the price to be back to its original state
I use this code to update price
Create procedure edittheprice
@price float,
@barcode int
as
update tblproducts set Price=@prices where Barcode = @barcode
Thanks to everyone
Upvotes: 0
Views: 53
Reputation: 97
It seems that this is more of a data model issue than stored procedure. since the new price is periodic, a separate table will be helpful. For example, a discount_prices table as below:
product_id | discounted_price | valid_from | valid_to
Joining this with the product table helps you know current actual price and will also help you track the prices over time.
Upvotes: 2