FTP a file from a Server's Subfolder using PL/SQL - oracle

I'm trying to get a file from a Windows Server to our Oracle Application Server directory named EXT_TAB_DATA.
I have followed the sample of a similar SO post (PL/SQL FTP API binary vs ascii mode), using Tim Hall's FTP Package.
Code Block
set serveroutput on
DECLARE
l_conn UTL_TCP.connection;
BEGIN
L_CONN := FTP.login (p_host => 'sample.corp.server' -- this is a sample, not the real IP address
p_user => 'corporate/user1', -- this is a sample, not the real User
p_port => '21',
p_pass => 'pwd');
ftp.binary(p_conn => l_conn);
ftp.get (p_conn => l_conn,
p_from_file => '101_Test.csv',
p_to_dir => 'EXT_TAB_DATA',
p_to_file => '101_Test_Trans.csv');
ftp.logout(l_conn);
END;
/
However, the file i'm trying to transfer is located in a subfolder named "Payroll_Folder" in "sample.corp.server.
Seems FTP.login only checks the main directory of the host, and not inside subfolders.
How can I get the the file '101_Test.csv' from the Server/Directory "sample.corp.server/Payroll_Folder"?

Change
p_from_file => '101_Test.csv'
to
p_from_file => 'Payroll_Folder/101_Test.csv'

Related

Oracle 11g data pump import job trying to create .DB files on the wrong drive

I know absolutely nothing about Oracle until attempting this restore. I have a .DMP file that I must restore. After many failed attempts I have issued the command:
alter system set DB_CREATE_FILE_DEST='E:\app\****\oradata\orcl';
because the data pump job keeps trying to put files on a D:\ that I cannot write to (it's a DVD drive). This DMP was created in Oracle 11g so that is what I've installed.
The error I get (many, many times) is like so:
O/S-Error: (OS 3) The system cannot find the path specified.
Failing sql is:
CREATE TABLESPACE "E:\APP\******\ORADATA\ORCL" DATAFILE 'D:\ORACLE\DATA\RRAEMR\LOGICIAN.DB' SIZE 251658240 AUTOEXTEND ON NEXT 5242880 MAXSIZE 2097152000,'D:\ORACLE\DATA\RRAEMR\LOGICIAN_DATA_0002.DB' SIZE 10
ORA-39083: Object type TABLESPACE failed to create with error:
ORA-01119: error in creating database file 'D:\ORACLE\DATA\RRAEMR\LOGIC_IX.DB'
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.
When I look at ALL_DIRECTORIES there is no directory pointed at D:\, all point to E:\ or C:\ or X:.
I should add that during the data pump import wizard I have tried remapping the tablespace files to where I want them and I do see some files landing there. I do not understand if this can be done for datafiles too. It looks like it should, but when adding a row and clicking it no datafile name is supplied like it was for tablespaces.
How can I restore this dump on a different drive?
EDIT:
Ok I am firing off another data pump import job without doing any remapping and within the first few seconds the log file already has errors like:
Failing sql is:
CREATE UNDO TABLESPACE "UNDOTBS" DATAFILE 'D:\ORACLE\DATA\RRAEMR\UNDOTBS01.DB' SIZE 20971520 AUTOEXTEND ON NEXT 5242880 MAXSIZE 2097152000,'D:\ORACLE\DATA\RRAEMR\UNDOTBS02.DB' SIZE 10485760 AUTOEXTEND ON NEX
ORA-39083: Object type TABLESPACE failed to create with error:
ORA-01119: error in creating database file 'D:\ORACLE\DATA\RRAEMR\TEMP_0003.DB'
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.
So it's still wanting to put on the D:. I captured the SQL for the job and here it is:
set scan off
set serveroutput on
set escape off
whenever sqlerror exit
DECLARE
s varchar2(1000);
h1 number;
errorvarchar varchar2(100):= 'ERROR';
tryGetStatus number := 0;
begin
h1 := dbms_datapump.open (operation => 'IMPORT', job_mode => 'FULL', job_name => 'IMP_SD_44-09_53_59', version => 'COMPATIBLE');
tryGetStatus := 1;
dbms_datapump.set_parallel(handle => h1, degree => 1);
dbms_datapump.add_file(handle => h1, filename => 'IMPORT-'||to_char(sysdate,'hh24_mi_ss')||'.LOG', directory => 'DMPDIR', filetype=>DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);
dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 1);
dbms_datapump.add_file(handle => h1, filename => 'RRA.DMP', directory => 'DMPDIR', filetype => 1);
dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1);
dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC');
dbms_datapump.set_parameter(handle => h1, name => 'REUSE_DATAFILES', value => 0);
dbms_datapump.set_parameter(handle => h1, name => 'TABLE_EXISTS_ACTION', value => 'REPLACE');
dbms_datapump.set_parameter(handle => h1, name => 'SKIP_UNUSABLE_INDEXES', value => 0);
dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0);
dbms_datapump.detach(handle => h1);
errorvarchar := 'NO_ERROR';
EXCEPTION
WHEN OTHERS THEN
BEGIN
IF ((errorvarchar = 'ERROR')AND(tryGetStatus=1)) THEN
DBMS_DATAPUMP.DETACH(h1);
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
RAISE;
END;
/

how i use plsql for sending csv file via FTP?

For the development of a solution of replication and consolidation between 2 schema oracle 10g distant. I want to use the FTP API (ftp.pks, ftp.pkb) to transfer a CSV file to an FTP server. when performing the dedicated procedure for that I have the error
ORA-31024: Parser initialization failed with LPX-54
error while parsing a stream to XOB
and I find no solution, can help me!
PROCEDURE ftpTransfer IS
vConn UTL_TCP.connection;;
vFileName VARCHAR2(50);
vToFile VARCHAR2(200);
BEGIN
fileTransfer(vFileName);
IF vFileName IS NULL THEN
raise_application_error(-20002,'FTP - Erreur de Fichier');
END IF;
vToFile := RPLPKG_PARAMETERS.gServer.sDir||vFileName;
vConn := ftp.login(RPLPKG_PARAMETERS.gServer.sHost, RPLPKG_PARAMETERS.gServer.sHost, RPLPKG_PARAMETERS.gServer.sPort, RPLPKG_PARAMETERS.gServer.sPsw);
ftp.ascii(p_conn => vConn);
ftp.put(p_conn => vConn,
p_from_dir => 'RPLDIRECTORY',
p_from_file => 'HRM10122019.csv',
p_to_file => '/JOURNALS/HRM10122019.csv');
ftp.logout(vConn);
END ftpTransfer;
screenshot

Oracle Datapump: Invalid operation at line 6224

I've a Oracle dump file that I'm trying to import to AWS RDS Oracle 12.1.0.2.v17
database.
The dump file looks like this:
$ strings EXPDP.dmp | head -n 6
_|lM
"PACOPROD"."SYS_EXPORT_SCHEMA_01"
IBMPC/WIN_NT64-9.1.0
unicode
AL32UTF8
12.01.00.00.00
The commands I'm running is:
DECLARE
hdnl NUMBER;
BEGIN
hdnl := DBMS_DATAPUMP.OPEN( operation => 'IMPORT', job_mode => 'SCHEMA', job_name=>null, version=>'COMPATIBLE');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'EXPDP.dmp', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.METADATA_FILTER(hdnl,'SCHEMA_EXPR','IN (''PACOPROD'')');
DBMS_DATAPUMP.START_JOB(hdnl);
END;
/
The response is:
Error report -
ORA-39002: invalid operation
ORA-06512: at "SYS.DBMS_DATAPUMP", line 6224
ORA-06512: at line 7
The closes similar issue I've found is this, even though it's not exactly the same error message and in my case both source and target db is running 12.1.
I think the issue is one of the following:
A) The DMP file is corrupt.
B) I'm doing something wrong.
I've no clue how to get further though. Where shall I dig or what should I try to go forward?
Try to add a log file to the operation. It some times contain more information:
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'EXPDP.log', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.KU$_FILE_TYPE_LOG_FILE);

Move a file from one server to another server via plsql or shell

I have a server with details :
server ip: 192.168.141.96 : 21 credentials: user: tss password: T#l30P#ss path: /home/ttt/
This is the server where a file is getting generated. I want to move this file to another server with credentials
Host: sftp://sftpabc.learn.com
User name: abc
Password: jQrE7wvg
Port: 22
import dir: upload/source
I am trying to use the following plsql script for this :
DECLARE
l_conn UTL_TCP.connection;
begin
l_conn := ftp.login('192.168.141.96', '21', 'tss', 'T#l30P#ss');
ftp.ascii(p_conn => l_conn);
FTP.GET(P_CONN => L_CONN,
P_FROM_FILE => 'filename_test.csv',
p_to_dir => 'DIR_INBOUND',
p_to_file => 'test_get.txt');
ftp.logout(l_conn);
END;
But this is not executing and no file is getting transgerred. Is there a shell script/plsql script for this ?
What do you mean by 'is not executing'. What is the error? A quick search shows that you may be using this site as reference for your code. If that is the case, did you make sure to compile the ftp.pks and ftp.pkb in your database?

Problem creating a Directory object in Oracle

The code is this:
Originally:(http://www.oracle-base.com/articles/misc/FTPFromPLSQL.php)
The approach uses a combination of the UTL_TCP and UTL_FILE packages to create a simple FTP API (ftp.pks, ftp.pkb). Once the API is loaded into the appropriate schema simple FTP commands can be initiated as follows:
CREATE OR REPLACE DIRECTORY my_docs AS '/u01/app/oracle/';
SET SERVEROUTPUT ON SIZE 1000000
#c:\ftp.pks
#c:\ftp.pkb
-- Send an ASCII file to a remote FTP server.
DECLARE
l_conn UTL_TCP.connection;
BEGIN
l_conn := ftp.login('ftp.company.com', '21', 'ftpuser', 'ftppassword');
ftp.ascii(p_conn => l_conn);
ftp.put(p_conn => l_conn,
p_from_dir => 'MY_DOCS',
p_from_file => 'test_get.txt',
p_to_file => '/u01/app/oracle/test_put.txt');
ftp.logout(l_conn);
END;
/
The problem is that when I try to create the directory object I get an error saying that Create symbol wasnt expected.
where this line should be created?
Is there anything preceding the create statement line in your script? It looks like there might be something you left off the post.

Resources