执行pl-sql过程时出错。
下面是我的剧本。
set serveroutput on size 100000
set echo off
set feedback off
set lines 300
declare
cursor sessinfo is
SELECT NVL(s.username, '(oracle)') AS username,
s.osuser,
s.sid,
s.serial#,
p.spid,
s.status,
s.module,
s.machine,
s.program,
TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time,
s.last_call_et/3600 last_call_et_Hrs,
lpad(t.sql_text,30) "Last SQL"
from gv$session s,
gv$sqlarea t,
gv$process p
where s.sql_address = t.address and
s.sql_hash_value =t.hash_value and
p.addr=s.paddr and
s.status='INACTIVE' and
s.last_call_et > (3600)
order by last_call_et;
sess sessinfo%rowtype;
sql_string1 Varchar2(2000);
sql_string2 Varchar2(2000);
begin
open sessinfo;
loop
fetch sessinfo into sess;
exit when sessinfo%notfound;
sql_string1 := 'sid=' || sess.sid ||
' serail#=' || sess.serial# ||
' machine=' || sess.machine ||
' program=' || sess.program ||
' username=' || sess.username ||
' Inactive_sec=' || sess.last_call_et ||
' OS_USER=' || sess.osuser;
sql_string2 := 'alter system kill session ' || chr(39) ||
sess.sid || ',' || chr(39) || sess.serial# || ';';
dbms_output.put_line(sql_string1);
dbms_output.put_line(sql_string2);
end loop;
close sessinfo;
end;
/
quit;
我收到以下错误。请帮帮我。
[oracle@localhost ~]$ sqlplus -s '/as sysdba' @inactive12.sql
sql_string1:='sid='||sess.sid||' serail#='||sess.serial#||' machine='||sess.machine||' program='||sess.program||' username='||sess.username||' Inactive_sec='||sess.last_call_et||' OS_USER='||sess.osuser;
*
ERROR at line 12:
ORA-06550: line 12, column 165:
PLS-00302: component 'LAST_CALL_ET' must be declared
ORA-06550: line 12, column 1:
PL/SQL: Statement ignored
答案 0 :(得分:5)
您将last_call_et
别名为last_call_et_hrs
,因此光标不再显示last_call_et
,请使用别名列last_call_et_hrs
。