發表文章

目前顯示的是 8月, 2015的文章

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. -- Defined DIR 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 ;