Home > mget  [1 example]

Get multiple files on the remote server.

 Examples

SET SERVEROUTPUT ON SIZE 1000000;
SET LINES 255;
DECLARE
  fid VARCHAR2(80);
  host VARCHAR2(80)   := '[replace with ftp address]';
  usernm VARCHAR2(80) := '[replace with ftp username]';
  passwd VARCHAR2(80) := '[replace with ftp password]';
  lv_result VARCHAR2(32767);
  l_list fclient_p.name_type;
  l_local_dir VARCHAR2(80) := 'c:\';
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.nameListStreamPath(fid, '/home/tester/test99');
  l_list := fclient_p.convertNameListToTables(lv_result);
  FOR i IN 1..l_list.COUNT LOOP
    DBMS_OUTPUT.PUT_LINE('Retrieving File : '||l_list(i));
    fclient_p.retrieveStream(fid, l_list(i), l_local_dir||SUBSTR(l_list(i), INSTR(l_list(i), '/', -1)+1));
    IF fclient_p.getLastResponseReturnCode(fid) = '226' THEN
      DBMS_OUTPUT.PUT_LINE('Retrieval Successful');
    ELSE
      DBMS_OUTPUT.PUT_LINE(SUBSTR('Retrieval Failed, Reason :'||REPLACE(fclient_p.getLastResponse(fid), CHR(10)), 1, 255));
    END IF;
  END LOOP;

  fclient_p.logout(fid);
  fclient_p.remove(fid);
EXCEPTION
  WHEN fclient_p.java_failed THEN
    DBMS_OUTPUT.PUT_LINE(SUBSTR(fclient_p.getErrorWithResponse(fid), 1, 255));
END;
/

Output: Retrieving File : /home/tester/test99/test.exe.1 Retrieval Successful Retrieving File : /home/tester/test99/test.exe.2 Retrieval Successful Retrieving File : /home/tester/test99/test99.exe Retrieval Successful Retrieving File : /home/tester/test99/test992.exe Retrieval Successful

 Related Commands
 delete
 ls
 mdelete
 mls
 
© 1999-2003 Bear Claw Inc.