FCOPY procedure - Copy text from one file to another
The FCOPY procedure copies text from one file to another.
Syntax
Procedure parameters
- location
- An input argument of type VARCHAR(128) that specifies the alias of the directory that contains the source file.
- filename
- An input argument of type VARCHAR(255) that specifies the name of the source file.
- dest_dir
- An input argument of type VARCHAR(128) that specifies the alias of the destination directory.
- dest_file
- An input argument of type VARCHAR(255) that specifies the name of the destination file.
- start_line
- An optional input argument of type INTEGER that specifies the line number of the first line of text to copy in the source file. The default is 1.
- end_line
- An optional input argument of type INTEGER that specifies the line number of the last line of text to copy in the source file. If this argument is omitted or null, the procedure continues copying all text through the end of the file.
Authorization
EXECUTE privilege on the UTL_FILE module.
Examples
Make a copy of a file, empfile.csv, that contains a comma-delimited list of employees from the emp table.
SET SERVEROUTPUT ON@
CREATE PROCEDURE proc1()
BEGIN
DECLARE v_empfile UTL_FILE.FILE_TYPE;
DECLARE v_dirAlias VARCHAR(50) DEFAULT 'empdir';
DECLARE v_src_file VARCHAR(20) DEFAULT 'empfile.csv';
DECLARE v_dest_file VARCHAR(20) DEFAULT 'empcopy.csv';
DECLARE v_empline VARCHAR(200);
CALL UTL_FILE.FCOPY(v_dirAlias,v_src_file,v_dirAlias,v_dest_file);
END@
CALL proc1@
This example results in the following output:
Return Status = 0
The
file copy, empcopy.csv, contains the following
data:
10,CHRISTINE,I,HAAS,A00,3978,1/1/1965,PRES,18,F,8/24/1933,52750,1000,4220
20,MICHAEL,L,THOMPSON,B01,3476,10/10/1973,MANAGER,18,M,2/2/1948,41250,800,3300
30,SALLY,A,KWAN,C01,4738,4/5/1975,MANAGER,20,F,5/11/1941,38250,800,3060
50,JOHN,B,GEYER,E01,6789,8/17/1949,MANAGER,16,M,9/15/1925,40175,800,3214
60,IRVING,F,STERN,D11,6423,9/14/1973,MANAGER,16,M,7/7/1945,32250,500,2580
70,EVA,D,PULASKI,D21,7831,9/30/1980,MANAGER,16,F,5/26/1953,36170,700,2893
90,EILEEN,W,HENDERSON,E11,5498,8/15/1970,MANAGER,16,F,5/15/1941,29750,600,2380
100,THEODORE,Q,SPENSER,E21,972,6/19/1980,MANAGER,14,M,12/18/1956,26150,500,2092