There are the following tables:
- The warehouse of raw materials: (ID, name, unit, price, quantity)
- Warehouse products: (ID, name, unit of measure, amount, quantity)
- Ingredients: (ID, products, raw material, quantity)
Ingredients - this recipe, which can be from raw materials, assemble products.
I known the product key that you need to make. Next, I need to choose all the ingredients for a desired product. Then, compare the amount of each of the necessary raw materials in the warehouse, required. If I have enough for each position of the required raw materials, to take the required number of ingredients from the warehouse of raw materials and produce 1 unit of output.
The idea is, it needs to produce 1 SQL procedure. After I get the list of ingredients (id_ингредиент, trabalhista), I have a two-dimensional table, and to work in SQL I can't with her.
I heard a little bit about cursors, to work with them do not know how, and it's due tomorrow.
In General, the program I have done, but the most part of calculations goes in the client part, because several times I pulled the DB and get all the classes fields.
I like this approach do not like, and I would like to know how you could do this job?