Oracle database
CREATE PROCEDURE copy_file(fromname VARCHAR2, toname VARCHAR2) AS BEGIN UTL_FILE.FCOPY('DIR1', fromname, 'DIR2', toname, 1, NULL); ...(7) RETURN; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('-- SQL Error --'); DBMS_OUTPUT.PUT_LINE('ERROR : ' || SQLERRM ); RETURN; END; / set serveroutput on call copy_file('file01.txt','file01_bk.txt');
Symfoware Server
CREATE FUNCTION copy_file(fromname VARCHAR, toname VARCHAR) RETURNS void AS $$ BEGIN PERFORM DBMS_OUTPUT.SERVEROUTPUT(TRUE); PERFORM UTL_FILE.FCOPY('/home/symfo', fromname, '/home/backup', toname, 1, NULL); ...(7) RETURN; EXCEPTION WHEN OTHERS THEN PERFORM DBMS_OUTPUT.PUT_LINE('-- SQL Error --'); PERFORM DBMS_OUTPUT.PUT_LINE('ERROR : ' || SQLERRM ); RETURN; END; $$ LANGUAGE plpgsql; SELECT copy_file('file01.txt','file01_bk.txt');
UTL_FILE.FCOPY(firstArg, secondArg, thirdArg, fourthArg, fifthArg, sixthArg)
If using a CREATE DIRECTORY statement (Oracle9.2i or later), specify a directory object name for the directory name.
A directory object name cannot be specified for the directory name.
Convert using the following procedure. Refer to UTL_FILE_DIR/CREATE DIRECTORY for information on how to check if the directory object name corresponds to the actual directory name.
Locate the places where the keyword "UTL_FILE.FCOPY" is used in the stored procedure.
Check the actual directory names ('/home/symfo' and '/home/backup', in the example) that correspond to the directory object names ('DIR1' and 'DIR2', in the example) of firstArg and thirdArg argument.
Replace the directory object name ('DIR1' and 'DIR2', in the example) with the actual directory names ('/home/symfo' in the example) checked in step 1.