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:
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;

Open in new window

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
Iver Erling ArvaSenior consultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
hmm, why do you think it's not working? You get exactly what you want: The reraised error.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Iver Erling ArvaSenior consultantAuthor Commented:
No, Where is the "File is already in use" text?

Iver
Iver Erling ArvaSenior consultantAuthor Commented:
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
Iver Erling ArvaSenior consultantAuthor Commented:
An error that wasn't an error after all. Just a misunderstanding on my part.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.