Iver Erling Arva
asked on
Oracle exception not called
Hi!
I am trying to include error handling in my PL/SQL command script, but it doesn't seem to get called when an error situation arises.
Here is some sample code to illustrate the problem:
Why doesn't this work?
Best regards
Iver Erling Arva, Oslo, Norway
I am trying to include error handling in my PL/SQL command script, but it doesn't seem to get called when an error situation arises.
Here is some sample code to illustrate the problem:
declare
out_file UTL_FILE.FILE_TYPE;
v_Fdir VARCHAR2(20):='TEMP_DIR_BEP';
v_Fname VARCHAR2(100):='BEP_Personkunder_over_62_ar_med_Pensjonskapital_mindre_enn_25%_av_G.xls';
begin
out_file := UTL_FILE.FOPEN(v_Fdir,v_Fname,'W');
-- here comes the rest of the code, but not necessary for this example
exception
WHEN UTL_FILE.FILE_OPEN THEN
DBMS_OUTPUT.PUT_LINE('File_is_already_in_use');
DBMS_OUTPUT.PUT_lINE(SQLERRM);
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('other write error');
DBMS_OUTPUT.PUT_LINE(SQLERRM);
RAISE;
end;
When I try to run this while the output file is open, I had expected to get a "File already in use" message, but instead I get an oracle error: ORA-29283: invalid file operation. ORA-06512 at "SYS.UTL_FILE", line 536. ORA-29283 invalid file operation. ORA-06512: at line 18. Line 18 is the RAISE:-line just above END;Why doesn't this work?
Best regards
Iver Erling Arva, Oslo, Norway
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
But you are right, it's just that the error is a different one than the one expected. I get the "Other file error" instead of the "FIle is already in use". That's what I found confusing.
Thanks!
IVer
Thanks!
IVer
ASKER
An error that wasn't an error after all. Just a misunderstanding on my part.
ASKER
Iver