Move file in Oracle PL/SQL
Here is a example of dynamically define directory in PL/SQL, then use file utility UTL_FILE to move or rename a file.
SELECT * FROM ALL_DIRECTORIES
-- mv file
DECLARE
vdir VARCHAR2 (255);
BEGIN
vdir := '/source_dir'||'/sub_dir';
EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY SRC_DIR AS ''' || vdir || '''';
vdir := '/dest_dir'||'/sub_dir';
EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY DEST_DIR AS ''' || vdir || '''';
UTL_FILE.FRENAME('SRC_DIR', 'src_filename.ext', 'DEST_DIR', 'dest_filename.ext');
END;
留言
張貼留言