Advertisement

07.12.2007 at 07:25AM PDT, ID: 22691787
[x]
Attachment Details

utl_file.INVALID_OPERATION error

Asked by ewang1205 in Oracle Database

Tags: utl_file

Hi, Experts,

I have a PROCEDURE to open a flat file.  The following is code;

 v_check_FHandle        UTL_FILE.FILE_TYPE;
  v_input_dir            varchar2(100) :='DEPWORK';
  v_input_file            varchar2(100);
  v_check_stmt               VARCHAR2(2000);
  v_check_cnt           number:=0;
  v_check_flag          boolean := TRUE;

      ---------------------------------------------
      -- Checking the Existance of the file
      ---------------------------------------------
begin
      BEGIN
      v_input_file := 'test_data.out';
          v_check_FHandle := utl_file.fopen(v_input_dir,v_input_file,'R');
          utl_file.get_line(v_check_FHandle, v_check_stmt);
          v_check_cnt := v_check_cnt + 1;
          utl_file.fclose(v_check_Fhandle);
          IF v_check_cnt > 0 then
            v_check_flag := FALSE;
          END IF;
        EXCEPTION
          When NO_DATA_FOUND then
          -- the file exists, but has zero bytes
          utl_file.fclose(v_check_Fhandle);
            v_check_flag := TRUE;
  WHEN utl_file.invalid_mode THEN
    RAISE_APPLICATION_ERROR (-20051, 'Invalid Mode Parameter');
  WHEN utl_file.invalid_path THEN
    RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location');
  WHEN utl_file.invalid_filehandle THEN
    RAISE_APPLICATION_ERROR (-20053, 'Invalid Filehandle');
  WHEN utl_file.invalid_operation THEN
    RAISE_APPLICATION_ERROR (-20054, 'Invalid Operation');
  WHEN utl_file.read_error THEN
    RAISE_APPLICATION_ERROR (-20055, 'Read Error');
  WHEN utl_file.internal_error THEN
    RAISE_APPLICATION_ERROR (-20057, 'Internal Error');
  WHEN utl_file.charsetmismatch THEN
    RAISE_APPLICATION_ERROR (-20058, 'Opened With FOPEN_NCHAR
    But Later I/O Inconsistent');
 WHEN utl_file.file_open THEN
    RAISE_APPLICATION_ERROR (-20059, 'File Already Opened');
 WHEN utl_file.invalid_maxlinesize THEN
    RAISE_APPLICATION_ERROR(-20060,'Line Size Exceeds 32K');
 WHEN utl_file.invalid_filename THEN
    RAISE_APPLICATION_ERROR (-20061, 'Invalid File Name');
 WHEN utl_file.access_denied THEN
    RAISE_APPLICATION_ERROR (-20062, 'File Access Denied By');
 WHEN utl_file.invalid_offset THEN
    RAISE_APPLICATION_ERROR (-20063,'FSEEK Param Less Than 0');
 WHEN others THEN
    RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
     end;
    BEGIN
   -- Open the input file for reading
   if v_check_flag then
   v_check_FHandle:=UTL_FILE.FOPEN(v_input_dir,v_input_file,'R');
   end if;
   DBMS_OUTPUT.PUT_LINE('File Opened for read.');
    end;
end;

When I run this in sqlplus, I got a error:
PLS-00483: exception 'INVALID_OPERATION' may appear in at most one exception handler in this block

Please help.  Thanks!

Start Free Trial
 
 
Loading Advertisement...
 
[+][-]07.12.2007 at 07:44AM PDT, ID: 19472247

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.12.2007 at 07:49AM PDT, ID: 19472317

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.12.2007 at 07:56AM PDT, ID: 19472414

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Tags: utl_file
Sign Up Now!
Solution Provided By: nav_kum_v
Participating Experts: 3
Solution Grade: A
 
 
[+][-]07.12.2007 at 07:56AM PDT, ID: 19472417

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32