I am doing an inventory management system rn and found a dead end on how i should do on my stock increases and decreases.
heres the thing,
if i ordered from supplier and set the stock status to "Ordered" the stock will remain unchanged and once I change the status to "Received" the quantity of product/stock i have order will be automatically added to my inventory table.
Where and how should i make to make this happened. my lecturer said smth about having a trigger. and i really dont know how to start. please give some input on how i should start. thanks in advance.
i'm using Tomcat 8.0, MySQL and JSP.
Related
I am looking for an Idea to handle data in DB directly.
Here is my use case
I have table “EVENT_REGISTERED” with column (ID, Event_name,Event_DateTime)
I want to display the EVENT_REGISTERED in the fronted end whose date and time is not passed. i.e. I want to display only Upcoming event not Historical events.
Of course this can be handle with JS code before displaying.
But What I want is there should be some sort of a trigger which will delete the Instance form the “EVENT_ REGISTERED” table and copy it to another Table “HISTORICAL_EVENT”
I cannot Create an MY SQL EVENT to do this as it like batch job and I cannot run this every 5 mins as there can be more than 10000 rows in there.
I see Trigger option as well, I am not sure how to use this as it says that it will be activated after the specific action is executed. Here the specific action is CURRENT_DATETIME == EVENT_DATETIME.
Can anybody give me a direction or any sort of alternative way to achieve this?
**I am not an Expert of MySQL*
Thank you
Regards
Prat
Don't start moving rows between tables. Simply run a query:
select er.*
from event_registered
where er.event_datetime > now();
With an index on (event_datetime), performance should be fine.
I have a query that would give me the opening stock for today, expected sales and purchases for the next few days (where there is no value for either, a null value is returned. What I would like to get to is to project the upcoming opening stock. How can I do this?
My current query would look very much like this in RedShift:
select date,opening_stock,sales,purchases
from inventoryandforecast
Current Output
I imagine that to accomplish the following output, I need to calculate a closing inventory for each day (where closing inventory = starting inventory - sales + purchases) and use either lag/lead for the opening inventory the next day, but I fail to understand how to do this. What should my query look like?
Intended output
Thank you for your time.
I'm trying to build a view that calculates the potential material quantities for my company. I'm doing this code in Microsoft SQL Server 2008.
In the view we have a Material Number, a date, demand quantity, received quantity, and an initial quantity.
I have a date listed for when the item demand is needed, and when items are expected to be received. On each listed date, I'd like to know what our inventory will look like for each item. In my head I have determined what I need is the following:
CurrentOnHand - DemandQuantity + ReceivedQuantity = NewTotal
The new total will move down to the next row and will take the spot of the CurrentOnHand, and the calculation will be performed for each date on the item.
How would I go about achieving this? Do I need to make some sort of running total? Any help would be greatly appreciated. Thank you for taking the time!
Corey Hall
I thought about using a trigger or function to solve the problem but I don't really know how to go about coding it. Any help would be much appreciated.
did you try to create view? view update every time a new row added or updated.
Views serve as query and look like a table.
IMHO you should not persist the running totals, the possibility of the value becoming stale is high, instead you should go the route of View as suggested by #m-farhan. Still if you would want to persist the running total, then Trigger would be the safest bet. The Trigger ideally should fire a SQL query to accumulate the Customer's total and update the Total's column.
I want to make an excel graphic with 3 values:
Sales Order Date (The date sales enters the sales order)
Requirement Date (The date the customer wants this order)
Closed Sales Order Date (When sales closes the order)
This will be used to measure the service of our plant against completed delivered sales orders monthly.
I already found the first 2 data cells on table VBMTV, anyone has an idea where can I get the information regarding as the date sales close the order once it has been delivered to the customer?
Regards,
Assuming that the data is displayed in a transaction, you can do the following:
position the cursor in the field you are interested in
press F1 - you get a help text in a dialog labeled 'Performance Assistant'
click the button for 'Technical Information' (looks like a hammer and wrench) - you'll get another dialog
in this dialog there are fields for 'Table Name' and 'Field Name'
For most transactions, this information maps to the specific tables/columns in the database. There are some exceptions to this rule (mostly for those cases where the data is not directly read from the db), but it is a good start and works for about 80% of the cases.
If F1 and Technical Information (F4) does not work you can also try running a trace using ST05. (Do this only for one user and make sure to disable the trace once you are done).
I believe Sales Order Complete may be a status. (TECO or "Technically Complete" if I'm correct). The table that stores the date a specific status was set is JCDS. You will have to read it on the OBJNR of the sales order and the internal status number of the status that you care about.