How to encapsulate code
Mark1970Jun 10 2010 — edited Jun 10 2010I've tried this query written by Steven Feuerstein that should be usefull for identifying all programs where a table or a view is referenced directly instead of an encapsulation package:
Another kind of standard that might be set within an organization is that application
code should never reference a table or view directly but instead always go through
an encapsulation package. Here is a query that identifies all program
units that violate this rule:
SELECT owner || '.' || name refs_table,
referenced_owner || '.' ||
referenced_name table_referenced
FROM all_dependencies
WHERE owner LIKE UPPER ('&1')
AND TYPE IN ('PACKAGE',
*'PACKAGE BODY',*
*'PROCEDURE',*
*'FUNCTION')*
AND referenced_type IN ('TABLE', 'VIEW')
ORDER BY owner,
name,
referenced_owner,
referenced_name;
Sorry (perhaps) for the question but I can't get as it works.
The query seems to find those procedures where there is a reference to a table. But how could that be different? I mean it's obvoius since whithin a package there are statements refering directly a table. Where didn't I undestand?
Thanks!
Edited by: Mark1970 on 10-giu-2010 7.14