我需要一个返回用户PID的函数。在this thread之后,我编写了以下函数:
CREATE OR REPLACE FUNCTION SPID
RETURN SMALLINT
AS
RES SMALLINT := 0;
BEGIN
SELECT PID INTO RES FROM V$PROCESS WHERE ADDR=(SELECT PADDR FROM V$SESSION WHERE SID=(SELECT SID FROM V$SESSION WHERE AUDSID=SPID()));
RETURN RES;
END;
然而,当我尝试做
时SELECT SPID() FROM DUAL;
我收到ORA-00600错误:
ORA-00600: internal error code, arguments: [KPDB-MAX_SWITCH], [], [], [], [], [], [], [], [], [],
ORA-06512: at "RNDSUITE.SPID", line 6
...
欢迎任何补救措施。
答案 0 :(得分:2)
你可以用这个pid:
select
pid,spid
from
v$process
where
ADDR=(select paddr from v$session where AUDSID=sys_context('USERENV', 'sessionid'));