开发者

How to move a text file using Oracle

开发者 https://www.devze.com 2023-01-12 15:14 出处:网络
I have two questions. (1) how to make move text file from folder: C:\\Data\\inbox\\test.txt to target Folder?

I have two questions.

(1) how to make move text file from folder:

C:\Data\inbox\test.txt

to target Folder?

C:\Data\outbox\test.txt

(2) how to make get list of directory files in Folder开发者_JAVA技巧?

C:\Data\inbox\

Thank you...


Oracle provides a package of utilities for working with files, UTL_FILE. Since 9i this has included the FRENAME() procedure, which works like the unix mv command. We can use it to rename the file and/or its directory. Note that the Oracle os account must have read and write privileges on both directories. Also this procedure uses DIRECTORY objects, rather than explicit paths.

As for getting a list of files in a directory, there is no Oracle built-in. One solution is to use a Java Stored Procedure. Tom Kyte has an example of this. Find it here. There is another way of doing it since 11.1.0.7, which is to use an external table pre-processor file. Adrian Billington wrote a nice article on this. The executed file is platform dependent.


Have a look at UTL_FILE?

http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm


Where you say:

2-) Question Two

Folder: C:\Data\inbox\

how to make get directory files list ?

Tom Kyte has a nice solution shown here


begin
  UTL_FILE.FCOPY (
   'EMPLOYEE'   , -- THIS IS A ORACLE DIRECTORY
   'EmpInfo.TXT'   , --FILE NAME
   'PROM_INCR'   , -- THIS IS A ORACLE DIRECTORY
   'EmpInfo.TXT' ); -- DESTINATION FILE
end;

try this

0

精彩评论

暂无评论...
验证码 换一张
取 消