Hello
I'm developing the logic to an application in PL/SQL and I ran into a problem that I can't solve.
I have a stage that will be fed frequently through another application. I need to insert this stage data into a final table, however, there are some rules:
Well, I know this is gonna be argued. A lot. But first of all, that is not a logic suitable to be implemented in PL/SQL. PL/SQL should be left fordatabase specific actions, not to implement the logic of the application. There is few cases in which I would recomend any kind of business logic to be implemented in PL/SQL. Distributing business logic across different layers is always trouble.
If you decide to go for the original language in which the application is (which I guess is not PL/SQL) create another question. If you go for PL/SQL that's the only way I can think of:
Create an internediate table in which keeping the records. This way the intermediate table will act as a cache, thread safe and transactional, in which easily manage the 3 business rulea that you posted.
Forneach request tjat you receive, query the intermadate table, donthe counting taking into acount table and request, amd act accordingly.
May be someone with better Oracle knowledge can think of something better. This is all I can think of, that's how I would do it. If someone gives a better PL/SQL solution I will delete this answer.