We've made a decision to layer some "parameterized views" over some regular views in Oracle in order to properly encourage correct where predicates to always be used in the queries.
The bulk of the repetitive code (tables joined appropriately) will be in the view, so that we will no longer have many different procedures and functions with their own copies of common joins and filters.
Then we will layer pipelined table functions over those views to ensure callers provide the necessary filters so that the views are not called "for all time and space". I have looked at alternatives using sys_context and userenv and package variables and although they appear to be what Oracle users call parameterized views, they simply are not viable to have those shims around a view every time it is used and they are not re-usable in self-joins.
I've read a lot about this in a variety of places, including StackOverflow:
Table-Valued Functions in ORACLE 11g ? ( parameterized views )
Is using a SELECT inside a pipelined PL/SQL table function allowed?
This is an architectural decision to try to improve the maintainability of an application which has become sprawling with a LOT of repeated queries. Views would go some way to helping, but I am worried that we have no way to enforce predicates on callers to stop them from doing silly things.
I've had a great deal of success using this technique in SQL Server with inline table-valued functions and it really helped make the system a lot more coherent and easier to track dependencies and effects of proposed changes, since there was a) less code and b) more re-use and less repetition.
I'm a little worried about that last link, it seems to imply that I might have concurrency or timing issues if I was to join one of these pipelined table functions and use it to update another table.
Please share your experiences with pipelined table functions and what I need to look out for? Also if there is a better alternative, let me know in your answer too?