ORA-01031: insufficient privileges error when try to flashback package, procedure etc. source.

When you try to flashback package, procedure etc. oracle launch Ora-01031: insufficient privileges error even if you have dba role privilege. only sysdba role privileged users can see result of fashback query.

SELECT TEXT
    FROM SYS.DBA_SOURCE
         AS OF TIMESTAMP TO_TIMESTAMP ('11.04.2022 09:00:00', 'dd.mm.yyyy hh24:MI:SS')
   WHERE name = 'MYPROC' AND TYPE = 'PROCEDURE' AND OWNER = 'ADMIN'
ORDER BY line;

[Error] Execution (23: 14): ORA-01031: insufficient privileges

There is a workaround. you need to grant source$ view to required user. and then query from source$ bring result to user without sysdba privilege.

grant flashback on source$ to user1;

conn user1/password

  SELECT TEXT
    FROM SYS.DBA_SOURCE
         AS OF TIMESTAMP TO_TIMESTAMP ('11.04.2022 09:00:00', 'dd.mm.yyyy hh24:MI:SS')
   WHERE name = 'MYPROC' AND TYPE = 'PROCEDURE' AND OWNER = 'ADMIN'
ORDER BY line;

ref: https://ora600tom.wordpress.com/2012/05/31/flashback-a-package-from-the-current-schema/

Leave a comment