ORA-06502: PL/SQL: numeric or value error: character to number conversion error
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');
iam getting this error when i excute this procedure i dont know where the exact error
What is the data type of stores_audit.audit_id? Its name suggest it may be numeric, but you are fetching a string into it.
精彩评论