当前位置:Gxlcms > mysql > scn_to_timestampORA-00904

scn_to_timestampORA-00904

时间:2021-07-01 10:21:17 帮助过:8人阅读

Oracle中scn与时间之间可以进行相互转换,朋友的数据库是10.2.0.5,之前通过scn_to_timestamp将scn转换为相对应的时间时一切正常

Oracle中scn与时间之间可以进行相互转换,朋友的数据库是10.2.0.5,之前通过scn_to_timestamp将scn转换为相对应的时间时一切正常,但今天执行却报错了。
SQL>select to_char(scn_to_timestamp(3111823),'yyyy-mm-dd hh24:mi:ss') from dual;
select to_char(scn_to_timestamp(3111823),'yyyy-mm-dd hh24:mi:ss') from dual;
*
ERROR at line 1:
ORA-00904: "SCN_TO_TIMESTAMP": invalid identifier

很奇怪,scn_to_timestamp函数的状态通过下面的查询语句来查询
SQL> select owner,object_name,object_type,last_ddl_time,status from dba_objects where object_name='SCN_TO_TIMESTAMP';

OWNER OBJECT_NAME OBJECT_TYPE LAST_DDL_TIME STATUS
------------ --------------------- ------------------- ------------- -------
SYS SCN_TO_TIMESTAMP FUNCTION 2014/11/26 12 VALID
PUBLIC SCN_TO_TIMESTAMP SYNONYM 2014/11/26 12 VALID


后来我把scn_to_timestamp函数的创建语句重新执行一次。
create or replace function scn_to_timestamp(query_scn IN NUMBER)
return TIMESTAMP
IS EXTERNAL
NAME "ktfexscntot"
WITH CONTEXT
PARAMETERS(context,
query_scn OCINUMBER,
RETURN)
LIBRARY DBMS_TRAN_LIB;


在执行完后执行对scn_to_timestamp函数的查询
SQL> select to_char(scn_to_timestamp(3111823),'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SCN_TO_TIMESTAMP(31118
------------------------------
2015-02-03 16:26:27


但是却新创建了一个scn_to_timestamp函数并没有替换掉原来的
SQL> select owner,object_name,object_type,last_ddl_time,status from dba_objects where object_name='SCN_TO_TIMESTAMP';

OWNER OBJECT_NAME OBJECT_TYPE LAST_DDL_TIME STATUS
----------- ------------------------ ------------------- ------------- -------
SYS SCN_TO_TIMESTAMP FUNCTION 2014/11/26 12 VALID
PUBLIC SCN_TO_TIMESTAMP SYNONYM 2014/11/26 12 VALID
SYS SCN_TO_TIMESTAMP FUNCTION 2015/2/3 16:5 VALID


这个问题还没找到原因,也许是oracle的bug,因为我在oracle 10.2.0.4中重新创建scn_to_timestamp函数后,查询dba_objects并没有显示生成的scn_to_timestamp函数
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as SYS

SQL>
SQL> create or replace function scn_to_timestamp(query_scn IN NUMBER)
2 return TIMESTAMP
3 IS EXTERNAL
4 NAME "ktfexscntot"
5 WITH CONTEXT
6 PARAMETERS(context,
7 query_scn OCINUMBER,
8 RETURN)
9 LIBRARY DBMS_TRAN_LIB;
10 /

Function created

SQL> select owner,object_name,object_type,last_ddl_time,status from dba_objects where object_name='SCN_TO_TIMESTAMP';

OWNER OBJECT_NAME OBJECT_TYPE LAST_DDL_TIME STATUS
---------- ------------------------ ------------------- ------------- -------
SYS SCN_TO_TIMESTAMP FUNCTION 2015/2/3 21:2 VALID
PUBLIC SCN_TO_TIMESTAMP SYNONYM 2008/4/23 12: INVALID

并且在10.2.0.4中重建scn_to_timestamp函数后,对应的同义词失效了,这才是正确而在10.2.0.5中重建scn_to_timestamp函数后,却产生了一个新的同名对象,且对应的同义仍然为有效状态。

本文永久更新链接地址

人气教程排行