Link to home
Start Free TrialLog in
Avatar of p baji
p baji

asked on

How to read .csv file from FTP or SFTP server using Oracle PL SQL ?

I tried the below code and it showing output like SSH-2.0-OpenSSH_5.3 that means connected i hope.

 declare c  utl_tcp.connection;  -- TCP/IP connection to the Web server ret_val pls_integer;
 BEGIN c := utl_tcp.open_connection(remote_host => 'ftp.******.******.com'
                                   ,remote_port =>  21 ,charset => 'US7ASCII' --                              
                                   ,wallet_path     => '****************' --                              
                                   ,wallet_password => '**********' );  -- open connection
--  ret_val := utl_tcp.write_line(c, 'GET / HTTP/1.0');    -- send HTTP request
ret_val := utl_tcp.write_line(c);
BEGIN LOOP dbms_output.put_line(utl_tcp.get_line(c, TRUE));  -- read result
 END LOOP;
EXCEPTION
WHEN utl_tcp.end_of_input THEN NULL; -- end of input
END;
utl_tcp.close_connection(c);
END;
/
Could someone help me on next steps on How to open and read the .csv file present in SFTP/FTP server and load it into Oracle DB table ?
Avatar of Sean Stuber
Sean Stuber

This article provides both source code and an example:

https://www.experts-exchange.com/articles/3043/How-to-FTP-with-Oracle-PL-SQL.html
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.