In Oracle PL/SQL, UTL_FILE.FCOPY procedure is used to copy a file. This article explains how to copy a file in PL/SQL using UTL_FILE.FCOPY procedure with syntax and examples.
Syntax
UTL_FILE.FCOPY ( src_location IN VARCHAR2, src_filename IN VARCHAR2, dest_location IN VARCHAR2, dest_filename IN VARCHAR2, start_line IN BINARY_INTEGER DEFAULT 1, end_line IN BINARY_INTEGER DEFAULT NULL);
Parameter Details
src_location | Location of the source file. (Directory Object Name) |
src_filename | Source File Name. |
dest_location | Destination for the copied file. (Directory Object Name) |
dest_filename | Destination file name. |
start_line | Line number at which to begin copying. The default is 1. |
end_line | Line number at which to stop copying. The default is NULL. |
UTL_FILE.FCOPY Examples
1. Example
The following example will copy the file emp.pdf in same directory MY_DOC with other name emp2.pdf.
BEGIN UTL_FILE.FCOPY ('MY_DOC', 'emp.pdf', 'MY_DOC', 'emp2.pdf'); END; /
2. Example
The following example will copy the file sqllog.log from one directory to another with just 3 lines only, starting from line number 1 to 3.
BEGIN UTL_FILE.FCOPY ('MY_DOC', 'sqllog.log', 'MY_DOC2', 'sqllog.log', 1, 3); END; /
See also:
- Move File From One Directory to Another in PL/SQL
- Split Large CSV into Multiple Files in Oracle
- Import CSV File Using Stored Procedure in Oracle
- Export CSV Data in Oracle using PL/SQL