Oracle PL/SQL: UTL_FILE.FCOPY Example

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_locationLocation of the source file. (Directory Object Name)
src_filenameSource File Name.
dest_locationDestination for the copied file. (Directory Object Name)
dest_filenameDestination file name.
start_lineLine number at which to begin copying. The default is 1.
end_lineLine 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:

Get more Vinish.dev tutorials on Google

See my articles more often when you search Google.

Vinish Kapoor
Vinish Kapoor

An Oracle ACE, author of four books on Oracle APEX, SQL and PL/SQL, and Oracle Forms, and a software developer building Oracle database applications since 2001.

guest

0 Comments
Oldest
Newest Most Voted