Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-09-27 : 09:21:46
|
Andrew writes "Hi there, I haven't developed any stored procs before and I'm looking for a bit of help. Hypothetical situation: I have a table of items. The columns are COLOUR, STOCK_AVAILABLE, LOWER_LIMIT, UPPER_LIMIT (key is COLOUR). The COLOUR field is obviously the colour of the item and the STOCK_AVAILABLE is the number remaining in stock.I would like to retain an overall contiguous set of numbers for the range of items in each colour, so LOWER_LIMIT is the beginning number of each colour in the contiguous set and UPPER_LIMIT is the end of that particular colour in the range. Example: COLOUR | STOCK_AVAILABLE | LOWER_LIMIT | UPPER_LIMITred | 100 | 1 | 100blue | 100 | 101 | 200green | 100 | 201 | 300 I hope this is clear. The stored procedure requirements: I would like to be able to perform an update so that when an item is purchased, the STOCK_AVAILABLE is updated for that colour, and the LOWER_LIMIT and UPPER_LIMIT fields for the whole table are re-calculated. Example: (a blue item is purchased.... the table should now look like this... note that the green record has also been updated) COLOUR | STOCK_AVAILABLE | LOWER_LIMIT | UPPER_LIMITred | 100 | 1 | 100blue | 99 | 101 | 199green | 100 | 200 | 299 Can anyone help with the stored proc syntax to do this ?? Help would be greatly appreciated. Thanks and Regards, Andrew." |
|
|
|
|
|