I’m starting work on a program which is perhaps most naturally described as a batch of calculations on database tables, and will be executed once a month. All input is in Oracle database tables, and all output will be to Oracle database tables. The program should stay maintainable for many years to come.
It seems straight-forward to implement this as a series of stored procedures, each performing a sensible transformation, for example distributing costs among departments according to some business rules. I can then write unit tests to check if the output of each transformation is as I expected.
Is it a bad idea to do this all in PL/SQL? Would you rather do heavy batch calculations in a typical object oriented programming language, such as C#? Isn’t it more expressive to use a database centric programming language such as PL/SQL?
Normally I say put as little in PL/SQL as possible – it is typically a lot less maintainable – at one of my last jobs I really saw how messy and hard to work with it could get.
However, since it is batch processing – and since the input and output are both the DB – it makes good sense to put the logic into PL/SQL – to minimize ‘moving parts’. However, if it were business logic – or components used by other pieces of your system – I would say don’t do it..