Skip to Main Content
  • Questions
  • Transfer the file between 2 Remote servers using FTP

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Subbarao.

Asked: February 20, 2007 - 4:56 pm UTC

Last updated: November 06, 2017 - 1:12 am UTC

Version: 10g

Viewed 10K+ times! This question is

You Asked

Hi Tom!

I am using TOAD (Windows OS)for my most database development and my database is on AIX m/c. Here i am planning to create csv file based on certain query with/out where clause and store the csv file in AIX machine (Server 1)'cos i can not save the file in local m/c (using UTIL file). I am fine at this movement. Now I would like to FTP this file from Server 1 to another server (Server2) which is on different AIX machine. I have tried using couple of methods being in one server transfer file using ftp to another server. But My need is being in Window m/s using TOAD (eveything in single Pl/sql program) create a file in Server 1 FTP to another server (Server 2). How can do this.

Thanks for support.

and Tom said...

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6379798216275#19264891198142

you can ftp from one database server to another FTP server using bfiles or blobs...

Rating

  (6 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, February 21, 2007 - 2:53 pm UTC

Hopefully in future releases Oracle enhances dbms_file_transfer package to transfer no database files as well.

Unload ref_cursor to .csv by FTP

Chris Poole, February 21, 2007 - 6:13 pm UTC

OK shameless plug coming up but it does directly answer the posters question, the easy way to dump a query to an FTP server is:

declare

  handle        xutl_ftp.session_handle;
  dumpquery     sys_refcursor;

begin

  handle := xutl_ftp.start_session('remote_host', 'username', 'password');

  open dumpquery 
  for select 
    to_char(empno)||','||
    ename||','||
    job||','||
    to_char(mgr)||','||
    to_char(hiredate)||','||
    to_char(sal)||','||
    to_char(comm)||','||
    to_char(deptno)
  from scott.emp;
    
  -- pass our query to the ftp server to store
  -- we have to specify the filename as cursors don't have a filename associated with them!
  xutl_ftp.put(handle, dumpquery, 'scott_emp.txt');

  xutl_ftp.end_session(handle);    
    
end;


This unloads the query straight into a text file on any FTP server. No intermediate file required.

http://www.chrispoole.co.uk/apps/xutlftp.htm

HTH

Chris

A reader, February 21, 2007 - 9:16 pm UTC

Chris,

If you make package body code(xutl_ftp) available to the users that will be great

Transfering File from Unix server to local windows machine

Debasish, March 22, 2007 - 7:51 am UTC

Hi Tom
thanks for advance, Please let me know how could i transfer a txt file from unix server to local windows machine.
actully at runtime from report I am sending the output to a text file. which is save into unix server but I am unable to print that file from that location for that I am trying to copy that file from remote unix server to local windows machine so I can print tha .TXT file.
Tom Kyte
March 22, 2007 - 9:42 am UTC

you would write a program....

or use a mount (shared filesystem)

or an existing program like ftp

or a web server to serve the file to a program that already exists (a browser)



I tried Chris's xutlftp

Kurt Look, March 22, 2007 - 11:14 pm UTC

I tried the FTP package Chris mentioned above
( http://www.chrispoole.co.uk/apps/xutlftp.htm ). It works really well. It is easy to install and the examples work as advertised, so I was productive with the package in no time. I had some questions and Chris has been very responsive. He's got a very nice offering for the community. I'd recommend it. By the way, I don't know Chris at all, so I'm praising his package on the merits.

Kurt

Shell Script for backup details updation

Surya, November 03, 2017 - 9:32 am UTC

Hi,

I am having a requirement. Can you please help me on how to achieve that - as I am pretty new to shell scripting.

My requirement is - I need to gather the backup details and need to save those backup details in a table which is residing on the other server. I had achieved reaching the other server. But after reaching there, its not connecting to the schema where I need to insert this backup information into a table. I am trying this through a shell script. But its not responding properly. Can you help me?
Connor McDonald
November 06, 2017 - 1:12 am UTC

Perhaps look at at external table where the pre-processor option actually runs your shell script.

So then the standard output from your shell becomes the rows in your external table. Then you can query that, append it to a clob, and store it.


More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here