Question: (By David Gray) I'm trying to
catch an ORA-01284 error in a stored procedure. Looking around it
seems as if I have to define my own exception using the PRAGMA
EXCEPTION_INIT key words and then tray the error in a when block.
The problem is I'm getting the following error when compiling:
Error(24,31): PLS-00109: unknown
exception name 'FILE_NOT_AVAILABLE' in PRAGMA EXCEPTION_INIT
The procedure is show below with the new code show in bold.
create or replace
PROCEDURE "MATERIALISE_DATA" (
p_filename varchar2,
p_recordcount OUT number,
p_errorcode OUT number
)
as
begin
declare
cursor c_v_logmnr_contents is
select
logmnr.logmnr_sequence.nextval as IDX,
V.*
from
v$logmnr_contents V
where
seg_owner = 'SONICA' and
operation in ('INSERT','UPDATE','DELETE');
output_rec
c_v_logmnr_contents%ROWTYPE;
v_idx number;
PRAGMA EXCEPTION_INIT(file_not_available,
-1284);
begin
p_recordcount := 0;
p_errorcode := 0;
begin
execute immediate 'truncate table
logmnr.logmnr_contents';
execute immediate 'commit';
end;
dbms_logmnr.add_logfile(LogFileName => p_filename, Options =>
dbms_logmnr.NEW);
dbms_logmnr.start_logmnr(DictFileName
=> 'G:\dtb1\TURLIVE\utl_dir_file\TURLIVE_DICTIONARY.ORA',
Options => dbms_logmnr.committed_data_only);
open c_v_logmnr_contents;
v_idx
:= 0;
loop
fetch c_v_logmnr_contents
into output_rec;
exit when c_v_logmnr_contents%NOTFOUND;
insert into logmnr.logmnr_contents values
output_rec;
v_idx
:= v_idx + 1;
end
loop;
commit;
close
c_v_logmnr_contents;
dbms_logmnr.end_logmnr;
dbms_output.put_line('.
');
dbms_output.put_line('Records fetched in cursor loop = ' || TO_CHAR(v_idx));
dbms_output.put_line('. ');
p_recordcount := v_idx;
rollback;
exception
when
file_not_available
then null;
when others then
p_errorcode := sqlcode;
end;
end;
Answer:
By Steve Callan: You need to declare declare
file_not_available as a
PL/SQL exception:
output_rec c_v_logmnr_contents%ROWTYPE;
v_idx number;
file_not_available
exception; --***********************
PRAGMA EXCEPTION_INIT(file_not_available,
-1284);
|
|
|
|
Guarantee your Success!
Oracle is the
world's most complex, robust and flexible database, considered
impossible to master without a mentor.
That's why all BC
Oracle trainers are working professionals, experts in Oracle who
share their tips and secrets. |
|
| |
|
Burleson is the American Team

Note:
This Oracle
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
Oracle forum.
Verify
experience!
Anyone
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
publish
their Oracle
qualifications.
Errata?
Oracle technology is changing and we
strive to update our BC Oracle support information. If you find an error
or have a suggestion for improving our content, we would appreciate your
feedback. Just
e-mail:
and include the URL for the page.
Copyright ? 1996 - 2012
All rights reserved.
Oracle ?
is the registered trademark of Oracle Corporation.
|
|