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>