Replacement for Pragma Restrict references

oracleoracle-11g-r2

Up to Oracle 11.1 you could mark a package as only reading from the database by adding
PRAGMA RESTRICT_REFERENCES( DEFAULT, WNDS);

This has now been deprecated. I would like to enforce read only on some of the packages.

  • it would help ensure that junior developers don't add new functionality that writes 'just because'
  • it makes granting execute on read only packages to report users cleaner

Is there any substitute that can enforce that a package only reads from the database?

Best Answer

I have several poor answers. I hope one of them works for you.

  1. Moving the packages to another schema may be an option. You might then grant that other schema a bare minimum set of privileges. This would get ugly for name resolution, though.

  2. Auditing the code by searching the schema might be another option:

    SELECT * FROM dba_source
    WHERE schema = 'ME'
      AND name LIKE 'MYPROC'
      AND (UPPER(text) LIKE '%UPDATE %'
           OR UPPER(text) LIKE '%INSERT %'
           OR UPPER(text) LIKE '%DELETE %');
    
  3. Defining the package as AUTHID CURRENT_USER would scale back the permissions at runtime to the calling user's permissions. This solution has its own can of worms.