日期:2014-05-17  浏览次数:21118 次

dbms_flashback.get_system_change_number是不是不能在存储过程中使用?
如题,
我单独使用时可以得到scn,我想写在存储过程中,由触发器来调用,将每次改变时的SCN记录到一个表中,发现存储过程里用不了dbms_flashback.get_system_change_number,写到动态sql中也不行,大家有什么好办法么?

------解决方案--------------------
你需要以sys账户登陆然后赋予你得用户execute on dbms_flashback权限,相关设置如下


Connected to Oracle9i Enterprise Edition Release 9.0.1.1.1
Connected as SYS


SQL> create user tmp profile "DEFAULT " identified by "tmp " default tablespace "USERS " temporary tablespace "TEMP " account unlock;

User created

SQL> grant "CONNECT " to tmp;

Grant succeeded

SQL> GRANT "DBA " TO TMP;

Grant succeeded

SQL> connect sys/change_on_install@orcl as dba;
Connected to Oracle9i Enterprise Edition Release 9.0.1.1.1
Connected as SYS

SQL> grant execute on dbms_flashback to tmp;

Grant succeeded

SQL> connect tmp/tmp@orcl;
Connected to Oracle9i Enterprise Edition Release 9.0.1.1.1
Connected as tmp

SQL> create table temp( i number );

Table created

SQL>
SQL> create or replace procedure sp_test
2 is
3 begin
4 insert into temp values( dbms_flashback.get_system_change_number );
5 end;
6 /

Procedure created

SQL>