I looked around the net for a while and seemed unable to find anything similar to what I wanted. I know this is due to the way I write my request, but any help would be appreciated.
The basics of what I'm trying to do is:
- Insert some items into the table if it does not exist
- Update item if it exists
It exists in the format:
name, barcode, element, quantity, location, price and date
name - can be used in several lines a barcode - for a specific element, but can be used as several locations item - this is the same as a barcode, but contains a name quantity - an obvious location - it can be different locations price - this binding to a specific item date - the last time this item was purchased
The difficulty is that a "name" can have several elements (barcode and element) in different places at different prices. The idea is that the customer can see how much they bought the item at a specific time, so they know how much they will need to sell.
However, the price they bought may vary, so they need to create another row in the table if the price is different from the previous purchase.
The idea of all this is to write down how much the “name” has each element in each place, and then the price they bought and when they last bought it.
Hope this makes sense.
In the psuedo code:
Insert into table if does not exist - name, barcode, item, quantity, location, price and date If name, barcode, item, location and price are the same - Update quantity and date (if more recent)