Move File from directories to another directories! [message #515049] |
Thu, 07 July 2011 22:34  |
|
I have two directories follow:
- The first directories1: "/home/oracle/xml" obitan file as: abc.xml, emp.xml...etc
- The second directories2: "/home/oracle/xml/move" is empty.
I want to move files from directories1 to directories2.How do i do?
|
|
|
|
|
|
|
Re: Move File from directories to another directories! [message #515061 is a reply to message #515054] |
Fri, 08 July 2011 00:33   |
 |
Barbara Boehmer
Messages: 9106 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
The following uses the get_dir_list function from one of your previous posts. It loops through a select from that function, copying one file at a time. The directory object names must be used in upper case. Substitute your own directory paths for mine in the example below when creating the directory objects. You may also need to grant read and write privileges through Oracle and the operating system.
-- starting files in directories:
SCOTT@orcl_11gR2> host dir c:\my_oracle_files\*.xml
Volume in drive C has no label.
Volume Serial Number is F0BB-93C9
Directory of c:\my_oracle_files
12/22/2010 11:57 AM 402 cadd_pass.xml
12/23/2010 02:27 AM 401 test.xml
06/15/2011 10:01 PM 596 your_file.xml
3 File(s) 1,399 bytes
0 Dir(s) 405,547,393,024 bytes free
SCOTT@orcl_11gR2> host dir c:\my_oracle_files\move\*.xml
Volume in drive C has no label.
Volume Serial Number is F0BB-93C9
Directory of c:\my_oracle_files\move
File Not Found
-- substitute your own directory paths when creating the directory objects:
SCOTT@orcl_11gR2> create or replace directory my_dir as 'c:\my_oracle_files'
2 /
Directory created.
SCOTT@orcl_11gR2> create or replace directory move_dir as 'c:\my_oracle_files\move'
2 /
Directory created.
-- copy the files:
SCOTT@orcl_11gR2> begin
2 for r in
3 (select *
4 from table (sys.get_dir_list ('C:\my_oracle_files\*.xml')))
5 loop
6 utl_file.fcopy
7 ('MY_DIR', -- must be in upper case
8 r.column_value,
9 'MOVE_DIR', -- must be in upper case
10 r.column_value);
11 end loop;
12 end;
13 /
PL/SQL procedure successfully completed.
-- results:
SCOTT@orcl_11gR2> host dir c:\my_oracle_files\move\*.xml
Volume in drive C has no label.
Volume Serial Number is F0BB-93C9
Directory of c:\my_oracle_files\move
07/07/2011 10:26 PM 402 cadd_pass.xml
07/07/2011 10:26 PM 401 test.xml
07/07/2011 10:26 PM 596 your_file.xml
3 File(s) 1,399 bytes
0 Dir(s) 405,547,393,024 bytes free
SCOTT@orcl_11gR2>
|
|
|
|
|
Re: Move File from directories to another directories! [message #515086 is a reply to message #515063] |
Fri, 08 July 2011 01:41   |
|
CREATE OR REPLACE Procedure Pro_Move_File_Xml(c_File_Name_In Varchar2) Is
c_Ten_File Varchar2(1000);
Begin
c_Ten_File := c_File_Name_In || '.xml';
Utl_File.Fcopy('XML', c_Ten_File, 'XMLDIR',c_Ten_File);
Utl_File.Fremove('XML', c_Ten_File);
End Pro_Move_File_Xml;
when i run proceduere that, see errors in file attach.
Please help me!
|
|
|
|
|
|