File open flags : UTL_FILE « System Packages « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE OR REPLACE PROCEDURE play_with_files
  2     (loc_in IN VARCHAR2,
  3      file_in IN VARCHAR2,
  4      mode_in IN VARCHAR2,
  5      mixed_up IN BOOLEAN := FALSE)
  6  IS
  7     fID UTL_FILE.FILE_TYPE;
  8     line VARCHAR2(32767) := 'fun stuff!';
  9  BEGIN
 10     IF mixed_up AND mode_in = 'R'
 11     THEN
 12        fID := UTL_FILE.FOPEN (loc_in, file_in, 'W');
 13     ELSIF mixed_up
 14     THEN
 15        fID := NULL;
 16     ELSE
 17        fID := UTL_FILE.FOPEN (loc_in, file_in, mode_in);
 18     END IF;
 19
 20     IF mode_in = 'R'
 21     THEN
 22        UTL_FILE.GET_LINE (fid, line);
 23        DBMS_OUTPUT.PUT_LINE ('Read from ' || file_in || ' in ' || loc_in);
 24     ELSE
 25        UTL_FILE.PUT_LINE (fid, line);
 26        DBMS_OUTPUT.PUT_LINE ('Wrote to ' || file_in || ' in ' || loc_in);
 27     END IF;
 28
 29     UTL_FILE.FCLOSE (fid);
 30  END;
 31  /
SQL>








31.38.UTL_FILE
31.38.1.File open and close with UTL_FILE package
31.38.2.File open flags
31.38.3.Save table records to a file
31.38.4.Use UTL_FILE package to create a file
31.38.5.Open a file with mode passed in
31.38.6.utl_file.invalid_&&firstparm
31.38.7.UTL_File related exception
31.38.8.UTL_FILE.IS_OPEN
31.38.9.A PL/SQL block to read an operating system file called BLOB.JPG that contains 1 row of binary data.