how use UTL_FILE package for write file on map drive? - oracle

I use UTL_FILE package in my procedure for saving file on database server but i need to save file on another server for that i make a map drive but this UTL_FILE not saving files on my MAP Drive me also check manually drive Read and write the file but through procedure UTL_FILE not ABLE TO save the file on map drive and i got this error "Data Base Error: ORA-29283: invalid file operation ORA-06512: at "SYS.UTL_FILE", line 536 ORA-29283: invalid file operation "

If it is a directory on a server that is not the database server, option that used to work for me was to use UNC (Universal Naming Convention) while creating directory (as an Oracle object). For example:
No : Z:\files_4005
Yes: \\my-another-server\d$\home\gis\files_4005"

Related

bulk import pdf files into oracle table

i have multiple folders on my disk and each folder has pdf files (4 files in each folder). How can i insert files in each folder in oracle table rows. the folder name will make primary key (being unique social svc #). i have used code as is from this link but i get following error:-
ora-22285 non-existent directory or file for fileopen operation
ora-06512 at sys.dbns_lob line 805
i ve also granted all permissions on the directory to my user with command:-
grant all on directory blob_dir to testuser
pl tell me what am i doing wrong.
if you going to use BLOB data type then you can upload data from external file using SQL*Loader. In case you are going to use BFILE then you just need to copy files into Oracle Server file system and grant access to it via DIRECTORY object with READ privelege. BFILE provides read only access to external files via SQL.

Oracle DATAPUMP import failed

I am currently trying to import a database using DBMS_DATAPUMP in PL/SQL using the following script.
DECLARE
h1 NUMBER;
BEGIN
h1 := DBMS_DATAPUMP.OPEN('IMPORT', 'FULL', NULL, DBMS_SCHEDULER.generate_job_name, 'LATEST');
DBMS_DATAPUMP.ADD_FILE(handle => h1, filename => 'EXAMPLE6.DMP', directory => 'DUMP');
DBMS_DATAPUMP.START_JOB(h1);
dbms_datapump.detach(h1);
END;
/
Everytime I execute this code, I get the following error message.
ERROR in line 1:
ORA-39001: invalid argument value
ORA-06512: in "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: in "SYS.DBMS_DATAPUMP", line 4929
ORA-06512: in "SYS.DBMS_DATAPUMP", line 5180
ORA-06512: in line 5
I already googled the error, but the answer mostly consisted of checking if the directory was already created and if the user had read and write access to the directory.
I also tried the impdp tool just as an experiment, to see if I could execute imports that way.
impdp pdb2 directory="DUMP" dumpfile="EXAMPLE6.DMP"
Based on the user I am executing impdp as, I get different error messages.
As a user with all privileges granted:
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-39155: error expanding dump file name "C:\Users\...\EXAMPLE6.DMP"
ORA-48128: opening of a symbolic link is disallowed
As the sysdba user:
ORA-39002: invalid operation
ORA-39070: unable to open the log file
ORA-39087: directory name DUMP is invalid
As I already said, the directory does exist on my drive, I created the directory called DUMP in Oracle and granted read and write access to my user.
All help would be appreciated and I would be happy to clarify if I wrote something confusing!
Edit:
Output of select directory_name, directory_path from dba_directories;
DIRECTORY_NAME
--------------------------------------------------------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
DUMP
C:\Users\Nemanja\Desktop\oraclePLS
I forgot to mention, that the Oracle service has complete access to the specified Windows directory.

How to import dmp file to oracle DB via SqlDeveloper or CMD in windows?

I have an Oracle dump file that got exported from an unfamiliar database.
I need to import it to my Oracle DB with either SqlDeveloper or command line in windows.
When using Data Pump Import Wizard in SqlDeveloper I'm getting the below error:
ORA-00942: table or view does not exist
When using the CMD I'm getting the below error:
ORA-39002: invalid operation ORA-39070: Unable to open the log file. ORA-29283: invalid file operation ORA-06512: at "SYS.UTL_FILE", line 536 ORA-29283: invalid file operation
My command line:
impdp USER/password DUMPFILE=c:\folder_name\file_name.dmp TABLES=All LOG=dump_log.log
I tried different variations and each time the same error.
Thank you for your help.
The command is missing the directory or the files in the proper directory on the db server. The default is DATA_PUMP_DIR which can be found from the DB as follow.
SQL> SELECT directory_name, directory_path FROM dba_directories
2 WHERE directory_name='DATA_PUMP_DIR';
DIRECTORY_NAME DIRECTORY_PATH
_________________ _________________________________________________________________
DATA_PUMP_DIR /opt/oracle/admin/ORCL/dpdump/8967C87908440D12E053020011AC6F8A
To make a new directory:
CREATE DIRECTORY MY_DIR AS 'c:\folder_name\';
Then add the directory and remove the path from the file parameter.
impdp USER/password directory=MY_DIR DUMPFILE=file_name.dmp TABLES=All LOG=dump_log.log
ref:
IMPDP > https://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_import.htm#SUTIL907
Create directory > https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_5007.htm#SQLRF01207

plsql CSV file reading and write

OWNER SYS
DIRECTORY_NAME ME
DIRECTORY_PATH \\172.16.20.11\Mad\
begin
vSFile := utl_file.fopen('ME','20170405.csv','R');
IF utl_file.is_open(vSFile) THEN
LOOP
i am getting error :
ORA-29283: invalid file operation ORA-06512: at "SYS.UTL_FILE", line 536 ORA-29283: invalid file operation ORA-06512: at "MADHUR.MSP_UPD_DAILYSALESFRMSAP", line 28 ORA-06512: at line 1
29283. 00000 - "invalid file operation"
*Cause: An attempt was made to read from a file or directory that does
not exist, or file or directory access was denied by the
operating system.
*Action: Verify file and directory access privileges on the file system,
and if reading, verify that the file exists.
Your error tells you exactly what the problem is:
*Cause: An attempt was made to read from a file or directory that does
not exist, or file or directory access was denied by the
operating system.
and what to do to fix it:
*Action: Verify file and directory access privileges on the file system,
and if reading, verify that the file exists.
So you specify:
DIRECTORY_PATH \\172.16.20.11\Mad\
are you able to actually access \\172.16.20.11\Mad\ with your oracle user?
if not, then you need to grant read, write on directory to user and also check OS permissions for your user to that path.
but also consider doing a network share to drive letter, instead of UNC path.
The reason for getting such issue is that you dont have read or write permission to the directory.
Run the below query to see if you have read and write priviledges:
SELECT *
FROM all_tab_privs
WHERE table_name = 'your_directory name';
If you find dont have any access then grant read and write privs.
SQL>CREATE OR REPLACE DIRECTORY dir1 as '/opt/oracle/';
SQL>GRANT READ,WRITE on dir1 to <Required user>; (if you want to give access to particular user)
OR
SQL>GRANT READ,WRITE on dir1 to PUBLIC; (if you want to give access to all users then give access to public)

Cannot write file xml output form a procedure - ORA-06512: a "SYS.UTL_FILE"

in our production environment we use a procedure that read from our DB Oracle 12c and write about 2000 files xml in output on the filesystem, all in the same directory.
Now we have a problem: after that 1400 files are already writed, the procedure fails with error:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
There is enough space on the filesystem to write the files and i have already checked the permissions.
In the procedure we call:
xdb.dbms_xslprocessor.clob2file(xml_document,R_FILE_FOLDER,substr(xml_file_name,0,instr(xml_file_name,'.',-1)-1)||'.unc',nls_charset_id('AL32UTF8'));
Thank you

Resources