The situation like this, if you are developing an application that manages an inventory and when a product reaches to its re-order level, your application should automatically populate and send a purchase order to the supplier. Then how is it possible through triggers?
-
Why triggers? Why can't your application just check the data itself and invoke the service?J Cooper– J Cooper2012-02-01 05:04:07 +00:00Commented Feb 1, 2012 at 5:04
-
1In a production system, I would imagine these kind of tasks would run as batch processes once a day or every so many hours or something - I mean think about it. Does it really matter if the supplier get's a purchase order the instant you reach re-order level or a couple hours later with all the other items for that day in bulk?J Cooper– J Cooper2012-02-01 05:06:52 +00:00Commented Feb 1, 2012 at 5:06
2 Answers
Create an ON UPDATE trigger which checks the stock level and then invokes your external purchase-order-creator when it's below a threshold.
Do you have a more specific question, possibly with some code?
1 Comment
Having triggers invoke external business services seems rather awkward.
Here are some other options:
Have the application be responsible for checking the data and invoking the service.
If the data is being updated by multiple applications, create a middle-man business service that will be responsible for updating the data and invoking the service through which all other applications must go through
Invoke the service through a batch process that runs every few hours, daily etc.. As in my comment, does it really matter if the supplier receives purchase orders within seconds?
If you really want to use triggers, you could use triggers to populate a 'Pending purchase orders' table in combination with a batch process that would periodically create purchase orders using data from table.
Just my two cents