Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Why not getting INVALID_PATH?

Re: Why not getting INVALID_PATH?

From: <tedchyn_at_yahoo.com>
Date: Wed, 22 Dec 1999 15:18:01 GMT
Message-ID: <83qq34$nbh$1@nnrp1.deja.com>


In article <38603ABA.E2B4CA13_at_bigfoot.com>,   Doug Cowles <dcowles_at_bigfoot.com> wrote:
> Small piece of code utilizing UTL_FILE package.
> I'm trying to open up a file that does not exist -
> and I am getting - through use of an OTHERS handler
> SQLCODE=1
> SQLERRM=User defined exception.
> I haven't defined any exceptions.
> I'm wondering why I don't get "Invalid_path"
> Remember..the file is non-existent
> Here's the code
>
> create or replace procedure foo as
> location VARCHAR2(30) :=/home/dropship
> filename VARCHAR2(30;
> open_mode VARCHAR2(30):='r';
> handle UTL_FILE.FILE_TYPE;
> v_error_code NUMBER;
> v_error_msg VARCHAR2(250);
> BEGIN
> filename:='Non existant';
> handle:=utl_file.fopen(location,filename,open_mode);
> EXCEPTION
> WHEN UTL_FILE.INVALID_PATH
> THEN dbms_output.put_line('Invalid Path');
> WHEN OTHERS
> THEN
> v_error_Code := SQLCODE;
> v_error_msg := substr(SQLERRM,1,250);
> dbms_output.put_line(sqlcode||' '||sqlerrm);
> dbms_output.put_line('Others excetion handler ');
> END;
>
> Now when I run this - why do I get
>
> SQL> exec foo;
> 1 User-Defined Exception
> Others exception handler
>
> PL/SQL procedure successfully completed.
>
> Shouldn't I get Invalid Path?
> And if not Invalid path, why user defined? I didn't define anything...
>
> - Dc.
>
>

doug, i ran you code and got invalid path. ted   1 create or replace procedure foo as

  2   location        VARCHAR2(30) :='/home/dropship';
  3   filename      VARCHAR2(30);
  4   open_mode  VARCHAR2(30):='r';
  5   handle          UTL_FILE.FILE_TYPE;
  6 v_error_code NUMBER;
  7 v_error_msg VARCHAR2(250);
  8 BEGIN
  9 filename:='Non existant';
 10 handle:=utl_file.fopen(location,filename,open_mode);  11 EXCEPTION
 12 WHEN UTL_FILE.INVALID_PATH
 13 THEN dbms_output.put_line('Invalid Path');  14 WHEN OTHERS
 15     THEN
 16       v_error_Code := SQLCODE;
 17       v_error_msg := substr(SQLERRM,1,250);
 18       dbms_output.put_line(sqlcode||'    '||sqlerrm);
 19       dbms_output.put_line('Others excetion handler ');
 20* END;
SQL> / Procedure created.

SQL> set serveroutput on
SQL> exec foo;
Invalid Path

PL/SQL procedure successfully completed.

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Dec 22 1999 - 09:18:01 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US