create or replace procedure summery_report_date_range (start_date in varchar2 , end_date in varchar2 )
is
cursor cursor_audit is SELECT audit_action, COUNT(audit_action), audit_user, audit_date ,
TABLE_NAME
FROM (
select audit_action, audit_user, audit_date, 'store_audit' TABLE_NAME
from stores_audit
UNION ALL
select audit_action, audit_user, audit_date, 'customer_audit' TABLE_NAME
from customer_audit
UNION ALL
select audit_action, audit_user, audit_date, 'category_audit' TABLE_NAME
from category_audit
UNION ALL
select audit_action, audit_user, audit_date, 'orders_audit' TABLE_NAME
from orders_audit
)"MYTBL"
where (audit_date between TO_DATE(start_date, 'DD-MON-YY') and TO_DATE(end_date, 'DD-MON-YY') )
GROUP BY audit_action, audit_user, audit_date, TABLE_NAME
ORDER BY audit_user;
rec_user stores_audit.audit_user%TYPE;
rec_total number;
rec_action stores_audit.audit_action%TYPE;
rec_date stores_audit.audit_date%TYPE;
rec_id stores_audit.audit_id%TYPE;
begin
open cursor_audit;
fetch cursor_audit into rec_action, rec_total,rec_user,rec_date,rec_id ;
while cursor_audit%found
loop
dbms_output.put_line('User : '||rec_user ||', Action : ' ||
rec_action ||', Date From: ' ||start_date ||' To ' || END_DATE || ' Total Action : ' || rec_total );
fetch cursor_audit into rec_action, rec_total, rec_user,rec_date,rec_id ;
end loop;
close cursor_audit;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Data Not Found.');
WHEN INVALID_CURSOR THEN
DBMS_OUTPUT.PUT_LINE('INVALID_CURSOR.');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM || ' ' ||SQLCODE);
end;
/
execute summery_report_date_range('01-DEC-10' , '31-DEC-10');
当我执行程序时我收到此错误我不知道确切错误在哪里
答案 0 :(得分:1)
stores_audit.audit_id的数据类型是什么?它的名字表明它可能是数字,但是你要在其中输入一个字符串。