variable B1 varchar2(30);variable B2 varchar2(30);variable B3 varchar2(20);variable B4 varchar2(20);exec :B1:='CHKKP_NEW'exec :B2:='CHKKP_NEW'exec :B3:='CHKKP_NEW'exec :B4:='CHKKP_NEW'set serveroutput ondeclarev_count number;beginfor i in 1..100 loopSELECT count(*) into v_count FROM CHKRULE_D WHERE RULETYPE=:B4 AND NVL(ITEM, :B3 ) = :B3 AND NVL(MODEL, :B2 ) = :B2 AND NVL(CUSTITEM, :B1 ) = :B1 ORDER BY RULESEQ DESC;dbms_output.put_line('Total ROws: ' || v_count);end loop;end;/select sid,serial# from v$session where sid in (select sys_context('USERENV','SID') from dual);
17:38:45 SQL> exec dbms_system.set_sql_trace_in_session(314,43729,false);已順利完成 PL/SQL 程序.
alter system set events 'sql_trace [sql:3jw2927kh51wb] bind=true,wait=true';alter system set events 'sql_trace [sql:0zsvnxk40mbft] bind=true,wait=true';
[oracle@xxxxxx trace]$ ls -ltr|grep trc|grep _ora_-rw-r----- 1 oracle dba 154002 May 10 17:48 xxxxxx_ora_7977.trc[oracle@xxxxxxx trace]$ less xxxxx_ora_7977.trc