ORA-22288: file or LOB operation FILEOPEN failed Permission denied
I have installed Oracle XE (Universal) on Fedora Core 8
I am trying to update Apex to 3.1.1. I have downloaded and extracted the zip file using unizp apex_3.1.1.zip
I ran @apexins SYSAUX SYSAUX TEMP /i/
and @apxchpwd
Both were successful
Now when I am executing this
@apxldimg.sql /home/myuser
I am getting
Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
PL/SQL procedure successfully completed.
old 1: create directory APEX_IMAGES as '&1/apex/images'
new 1: create directory APEX_IMAGES as '/home/myuser/apex/images'
Directory created.
declare
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
Permission denied
ORA-06512: at "SYS.DBMS_LOB", line 523
ORA-06512: at "SYS.XMLTYPE", line 287
ORA-06512: at line 15
PL/SQL procedure successfully completed.
Commit complete.
timing for: Load Images
Elapsed: 00:00:00.06
Directory dropped.
Kindly help.
I had the same problem on centos (RHEL 5.2). It think maybe it is something to do with permissions with the folder to which you extract the software. I unziped apex download in the home for the super user /root then changed directory to /root/apex to do the install. In sqlplus connected as sys as sysdba the command @apxldimg.sql /root failed with ora-22288. My workaround was to copy the images to a different directory and then it worked. rm -rf /tmp/apex/images/ then mkdir -p /tmp/apex/images/ then cp -r /root/apex/images/* /tmp/apex/images/ then back in sqlplus @apxldimg.sql /tmp. This time it worked!
Similar Messages
-
ORA-22288: file or LOB operation FILEOPEN failed (The data is invalid)
Dear All,
I am trying to insert a image file (gif) to one of my field.
1. Here is my table structure and trying to insert gif image file to PIC file.
SQL> desc cis2.david_pic
Name Null? Type
ID VARCHAR2(5)
PIC BLOB
2. I using sql command to create directory and the path is pointing where the DB
server was installed.
SQL> create or replace directory MY_FILES as '\\hkqaa-db1\TEXT_IMPORT';
3. Written a script to insert empty blob first and than trying to use the dbms_lob.fileopen
to upload the gif file.
SQL> declare
2 l_blob blob;
3 l_bfile bfile;
4 begin
5 insert into cis2.david_pic values ( '1', empty_blob())
6 returning pic into l_blob;
7 l_bfile := bfilename('MY_FILES', 'bess_signature.gif');
8 dbms_lob.fileopen(l_bfile);
9 dbms_lob.loadfromfile(l_blob, l_bfile, dbms_lob.getlength(l_bfile));
10 dbms_lob.fileclose(l_bfile);
11 end;
12 /
4. After I ran my script I got this error message.
declare
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
The data is invalid.
ORA-06512: at "SYS.DBMS_LOB", line 475
ORA-06512: at line 8
Can any tell me what wrong? is this the way to insert image?
ThanksKnow this is an old post: (for sharing sake.)
Please try avoiding
1. the 'hyphen' in between the path (hkqaadb1 instead of hkqaa-db1)
2. Give direct path like 'C:\TEXT_IMPORT' instead of network path.
create or replace directory MY_FILES as '\\hkqaa-db1\TEXT_IMPORT'; -- Not working.
create or replace directory MY_FILES as 'C:\hkqaadb1\TEXT_IMPORT'; -- Working.
and this worked fine.
Edited by: Arunan.KL on Mar 23, 2011 5:04 PM -
Getting ORA-22288: file or LOB operation FILEOPEN failed in Windows XP
Hi All,
I am getting the error message
ORA-22288: file or LOB operation FILEOPEN failed
when I attempt to call a stored procedure containing the following code.
bfile_in := BFILENAME( 'SP_IMPORT_NIF20_DIR', v_filename );
/* Open the input file */
DBMS_LOB.FILEOPEN(bfile_in);
It works fine on UNIX but fails when running on my Windows XP Pro Oracle 9i install. I suspect that it has something do to with the file permissions. I can get this same error on UNIX if the file permissions are not set correctly. I get it every time on Windows XP Pro even though I think that the file permissions are
set correctly. Perhaps the Windows XP Pro permissions are not as I think! or perhaps the Oracle instance needs to be granted access to the XP directories etc. I am not sure how this would be done.
Any suggestions much appreciated.You have EXPLORER set to "Use Simple File Sharing". Uncheck that option for the folders and you will get the security tab.
I am not sure why you can't run Oracle as a specific user. I do this all the time. In fact, I create an Oracle group and add a user called Oracle and then configure that user/group for all the permissions it needs (and none it doesn't), environment set up, etc. and then run the service as that user. Can you get a specific error message?
As a side note, I am clueless why Oracle doesn't do this for you. They do on Unix installs. -
Good day!
I'm just new with using databases, and i'm enjoying it.
So I read that you can insert images to a table, and so i decided to try it... and here's where I'm at..
*I made a directory
CREATE directory image_dir as 'D:\Images';
--Directory Created.
*I created a table
CREATE TABLE animages
(aname VARCHAR2(40),
breedno NUMBER(10),
image_file BLOB,
image_name VARCHAR2(40),
CONSTRAINT aname_fk FOREIGN KEY (aname) REFERENCES clist(aname));
--Table Created.
*Then I made a procedure for inserting the images
CREATE OR REPLACE PROCEDURE insert_image_file (p_aname VARCHAR2, p_breedno NUMBER, p_image_name IN VARCHAR2)
IS
src_file BFILE;
dst_file BLOB;
lgh_file BINARY_INTEGER;
BEGIN
src_file := BFILENAME('IMAGE_DIR', p_image_name);
INSERT INTO animages
(aname, breedno, image_file, image_name)
VALUES (p_aname, p_breedno, EMPTY_BLOB(), p_image_name)
RETURNING image_file
INTO dst_file;
SELECT image_file
INTO dst_file
FROM animages
WHERE aname = p_aname AND image_name = p_image_name
FOR UPDATE;
DBMS_LOB.fileopen(src_file, DBMS_LOB.file_readonly);
lgh_file := DBMS_LOB.getlength(src_file);
DBMS_LOB.loadfromfile(dst_file, src_file, lgh_file);
UPDATE animages
SET image_file = dst_file
WHERE aname = p_aname AND image_name = p_image_name;
DBMS_LOB.fileclose(src_file);
END;
--Procedure Created.
*So i was able to do those but when i was trying to execute the procedure i get this error..
execute insert_image_file('African Elephant', 60, 'African_Elephant');
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
The device is not ready.
ORA-06512: at "SYS.DBMS_LOB", line 523
ORA-06512: at "SCOTT.INSERT_IMAGE_FILE", line 18
ORA-06512: at line 1
I've been looking for a solution for a day now, hope someone could help me, thanks.
BTW, I got the code for the PROCEDURE from a user named Aparna16, just did some minor editing so it would fit my tables, thanks.
And sorry if the post is too long.Hi;
ORA-22288:Error: ORA-22288
Text: file or LOB operation %s failed %s
Cause: The operation attempted on the file or LOB failed.
Action: See the next error message in the error stack for more detailed
information. Also, verify that the file or LOB exists and that the
necessary privileges are set for the specified operation. If the error
still persists, report the error to the DBA.
Regard
Helios -
INSERTING VIDEO : ORA-22288: file or LOB operation FILEOPEN failed
Hi
I'm trying to insert BFILE videos wih a procedure:
CREATE OR REPLACE PROCEDURE "SYSTEM"."NEWVIDEO" (vid in number,
descr in varchar2, name in varchar2)
as
videoOBJ ordsys.ordvideo;
ctx RAW(4000) := null;
begin
select V.video into videoOBJ
from video V
where V.identifier = vid
for update;
videoOBJ.setDescription(descr);
videoOBJ.setSource('file', 'VIDEO_DIR', name);
videoOBJ.setProperties(ctx, true);
update video V
set V.video = videoOBJ
where V.identifier = vid;
commit;
end;
when execting in SQLplus
SQL>create or replace directory VIDEO_DIR as '/bpmod61/VIDEOS';
SQL>begin newvideo(26,'system video','BPR.AVI');end;
I got this message:
ERROR at line 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "ORDSYS.ORDVIDEO", line 1260
ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory
ORA-06512: at "SYSTEM.NEWVIDEO", line 12
ORA-06512: at line 1
I checked permission privilege for directory and file access: everything grant to everyone.Thank you for the reply Larry
I tested my database using tutorial script viddemo.sql
and i get the same message
directory created and read granted on it to public
OWNER DIRECTORY_NAME
DIRECTORY_PATH
SYS VIDDIR
c:\video
When i try
SQL> DECLARE
2 obj ORDSYS.ORDVideo;
3 ctx RAW(4000) := NULL;
4 BEGIN
5 SELECT video into obj from T_VIDEO where id = 1 FOR UPDATE;
6 -- set description
7 obj.setDescription('Video from a BFILE');
8 -- set mimetype
9 obj.setMimeType('video/x-quicktime');
10 -- set source
11 obj.setSource('FILE', 'VIDDIR','Sample.mov');
12 -- import data
13 obj.import(ctx);
14 -- set video attributes
15 obj.setKnownAttributes('MOOV', 400, 300, 1024, 10, 3600,
16 36000, 'NONE', 256, 28000);
17 UPDATE T_VIDEO SET VIDEO=obj WHERE id=1;
18 END;
19 /
DECLARE
ERROR AT LINE 1 :
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "ORDSYS.ORDSOURCE", line 181
ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory
ORA-06512: at "ORDSYS.ORDVIDEO", line 517
ORA-06512: at line 13
Thank you for the help -
ORA-22288:file or LOB operation FILEOPEN failed while loading XML file.
Hello all,
I am getting the following error messages while loading XML file to Oracle 9i table.
declare
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory
ORA-06512: at "SYS.DBMS_LOB", line 504
ORA-06512: at line 10
The script I am using is all follows:-
1. Created a file ldxmldata.sh on unix server directory
dd conv=ucase if=$1|sed 's/<?XML/<?xml/'|sed 's/VERSION/version/'|sed 's
/RECORD/ROW/'|sed 's/DATE/TRANSDATE/'|sed 's/&/-/'|sed 's/\/DATE>// TRANSDATE>/'>$1.UCASE
sqlplus sales/sales@rac @upld.sql $1.UCASE
2. Created SQL file upld.sql on unix server
set serveroutput on
exec DBMS_JAVA.SET_OUTPUT(1000000);
@ldxml.sql bsl.xml.UCASE
commit;
exit
3. Created sql file ldxml.sql on unix server
declare
insCtx DBMS_XMLSave.ctxType;
rows number;
file bfile := bfilename('XML_DIR','&1');
charContent CLOB := ' ';
targetFile bfile;
warning number;
begin
targetFile := file;
DBMS_LOB.fileopen(targetFile, DBMS_LOB.file_readonly);
DBMS_LOB.loadfromFile(charContent,targetFile,DBMS_LOB.getLength(tar
getFile),1,1);
insCtx := DBMS_XMLSave.newContext('sales.s_price');
rows := DBMS_XMLSave.insertXML(insCtx,charContent);
DBMS_XMLSave.closeContext(insCtx);
DBMS_LOB.fileclose(targetFile);
end;
4. As Sys,
Created a directory XML_DIR and assigned it the path of Unix server directory
where the script files reside.
Granted read priviledge on XML_DIR to user sales.
I am getting the above error messages. Kindly help with some possible solution.
Arun Patodia
Bokaro Steel CityHi guys,
Sybrand, aplogoies, the second line of the error stack was on one line in the first post, full error stack below:
ORA-22288: file or LOB operation FILEOPEN failed
The program issued a command but the command length is incorrect.
ORA-06512: at "SYS.DBMS_LOB", line 716
ORA-06512: at "JLMS.LOAD_DATA_UTIL", line 417
ORA-06512: at line 2I have looked at that error code as you mentioned, but the second line here doesn't really help much.
Hoek, i took your advice and tried to replace FILEOPEN with OPEn but got the same error.
Just to clarify as well, I am not using UNC or relative file paths as I know that these can cause problems.
Rgds
Dan -
ORA-22288: file or LOB operation FILEOPEN failed
Hello,
I have a small db procedure that tries to load files into a tablecolumn using DBMS_LOB.LOADFROMFILE.
I use: create or replace directory FILES_DIR as '\\server\Attachments';
this is the place where the files are located. I can access this directory using my Windows login.
When i then execute 'select DBMS_LOB.FILEEXISTS', it says '1', so ok so far.
Before I can load I have to open the file using DBMS_LOB.OPEN.
However, when I execute the procedure it gives me the error ORA-222888...
My DB-services are started using my Windows login.
If I try to map a network drive like z: = '\\server\Attachments', DBMS_LOB.FILEEXISTS says '0'.
How can it be that the DB says yes the file exists, but no I can't open it while the services are running with logins that can actually access the files?
I' ve searched the internet all day, is there a solution?
Thanks in advance,
Frankwhen I use the mapped drive, the file doesn't even exists for the db:
DBMS_LOB.FILEEXISTS says '0'.
when I use the UNC format, the file actually exists but then gives the error ORA-2228 on DBMS_LOB.OPEN.
So I tried net use z: \\server\attachments /USER:x\y in cmd, but the file still doesn't exist for the db
I also tried 'net use \\machine\..' like you proposed but can't seem to understand it's meaning.
The actual question is how can I let the file exist for the db using a mapped network drive? -
Hi Guys,
I'm trying to send BI publisher report output file attachment to user Notification through Workflow by using the code :
SELECT substr(file_name,instr(file_name,'/',-1,1)+1,length(file_name))
INTO get_file_name
FROM fnd_conc_req_outputs
WHERE concurrent_request_id = v_request_id;
src_lob := BFILENAME('CONC_OUTPUT', get_file_name);
DBMS_LOB.CREATETEMPORARY(dest_lob, TRUE, DBMS_LOB.SESSION);
DBMS_LOB.OPEN(src_lob, DBMS_LOB.LOB_READONLY);
DBMS_LOB.LoadFromFile( DEST_LOB => dest_lob,
SRC_LOB => src_lob,
AMOUNT => DBMS_LOB.GETLENGTH(src_lob));
DBMS_LOB.CLOSE(src_lob);
DOCUMENT_TYPE := 'application/excel;name:=test.xls' ;
dbms_lob.copy(document, dest_lob, dbms_lob.getlength(dest_lob));
Please Help to solve the Error.Appreciated for the Solution
Thanks,
Kishore Kandula.Hi
Is the 'CONC_OUTPUT' directory a DBA Directory? Run the query SELECT * FROM DBA_DIRECTORIES and see if this CONC_OUTPUT is a directory name. If not rather use one of the direcorties. -
UTL_SMPT ORA-22288: file or LOB operation GETLENGTH failed No such file or
Hello Everyone!
I am trying to write a script to send emails as an attachment(exists in the unix box) using utl_smtp
i have my reports in the directory : /opt/local/application/orafin/applmgr/out/outfaud. File existing in the directory is S1759.zip
i have created a directory as:
create or replace directory
REPORT_DIRECTORY
as
'/opt/local/application/orafin/applmgr/out/outfaud';
when i use BFILENAME as select BFILENAME('/oracle/oradata/bfiles', 'S1759.zip') from dual
output: REPORT_DIRECTORY//S1759.zip
my code is something like this
v_bfile:= BFILENAME(p_oracle_directory, p_file_name);
v_file_length := DBMS_LOB.GETLENGTH(v_bfile);
Error: ORA-22288: file or LOB operation GETLENGTH failed
No such file or directory
Could anyone please help me as im really struggling to fix this. Thanks!Thank you for the response..
v_bfile:= BFILENAME(p_oracle_directory, p_file_name);
-- Get the size of the file to be attached
v_file_length := DBMS_LOB.GETLENGTH(v_bfile);
-- Calculate the number of pieces the file will be split up into
v_pieces := TRUNC(v_file_length / v_amt);
-- Calculate the remainder after dividing the file into v_amt chunks
v_modulo := MOD(v_file_length, v_amt);
IF (v_modulo <> 0) THEN
-- Since the file does not devide equally
-- we need to go round the loop an extra time to write the last
-- few bytes - so add one to the loop counter.
v_pieces := v_pieces + 1;
END IF;
DBMS_LOB.FILEOPEN(v_bfile, DBMS_LOB.FILE_READONLY);
FOR i IN 1 .. v_pieces LOOP
-- we can read at the beginning of the loop as we have already calculated
-- how many iterations we will take and so do not need to check
-- end of file inside the loop.
v_buf := NULL;
DBMS_LOB.READ(v_bfile, v_amt, v_file_pos, v_buf);
v_file_pos := I * v_amt + 1;
UTL_SMTP.WRITE_RAW_DATA(p_conn, UTL_ENCODE.BASE64_ENCODE(v_buf));
END LOOP;
END;
DBMS_LOB.FILECLOSE(v_bfile);
end_attachment(p_conn => p_conn);
this is the existing code..so you which part of the code should i be replacing? im sorry im new to these concepts. thanks! -
ORA-22288: file or LOB operation GETLENGTH failed
I am using the following procedure for email the with attachment. it give the error, while I have check the directory rights is OK, also check the following thread
Error Message is ORA-22288: file or LOB operation GETLENGTH failed
but no result,
I do this on clone working fine, but production not working fine while I found one thing that the file generate in temp folder of clone while in Production did not generate.
CREATE OR REPLACE PROCEDURE APPS.mail_files (p_from_name VARCHAR2,
p_to_name VARCHAR2,
p_subject VARCHAR2,
p_message VARCHAR2,
p_oracle_directory VARCHAR2,
p_binary_file VARCHAR2)
IS
-- Example procedure to send a mail with an in line attachment
-- encoded in Base64
-- this procedure uses the following nested functions:
-- binary_attachment - calls:
-- begin_attachment - calls:
-- write_boundary
-- write_mime_header
-- end attachment - calls;
-- write_boundary
-- change the following line to refer to your mail server
v_smtp_server VARCHAR2(1000) := 'mail.company.com';
v_smtp_server_port NUMBER := 25;
v_directory_name VARCHAR2(1000) ;
v_file_name VARCHAR2(1000);
v_mesg VARCHAR2(32767);
v_conn UTL_SMTP.CONNECTION;
PROCEDURE write_mime_header(p_conn in out nocopy utl_smtp.connection,
p_name in varchar2,
p_value in varchar2)
IS
BEGIN
UTL_SMTP.WRITE_RAW_DATA(
p_conn,
UTL_RAW.CAST_TO_RAW( p_name || ': ' || p_value || UTL_TCP.CRLF)
END write_mime_header;
PROCEDURE write_boundary(p_conn IN OUT NOCOPY UTL_SMTP.CONNECTION,
p_last IN BOOLEAN DEFAULT false)
IS
BEGIN
IF (p_last) THEN
UTL_SMTP.WRITE_DATA(p_conn, '--DMW.Boundary.605592468--'||UTL_TCP.CRLF);
ELSE
UTL_SMTP.WRITE_DATA(p_conn, '--DMW.Boundary.605592468'||UTL_TCP.CRLF);
END IF;
END write_boundary;
PROCEDURE end_attachment(p_conn IN OUT NOCOPY UTL_SMTP.CONNECTION,
p_last IN BOOLEAN DEFAULT TRUE)
IS
BEGIN
UTL_SMTP.WRITE_DATA(p_conn, UTL_TCP.CRLF);
IF (p_last) THEN
write_boundary(p_conn, p_last);
END IF;
END end_attachment;
PROCEDURE begin_attachment(p_conn IN OUT NOCOPY UTL_SMTP.CONNECTION,
p_mime_type IN VARCHAR2 DEFAULT 'text/plain',
p_inline IN BOOLEAN DEFAULT false,
p_filename IN VARCHAR2 DEFAULT null,
p_transfer_enc in VARCHAR2 DEFAULT null)
IS
BEGIN
write_boundary(p_conn);
IF (p_transfer_enc IS NOT NULL) THEN
write_mime_header(p_conn, 'Content-Transfer-Encoding',p_transfer_enc);
END IF;
write_mime_header(p_conn, 'Content-Type', p_mime_type);
IF (p_filename IS NOT NULL) THEN
IF (p_inline) THEN
write_mime_header(
p_conn,
'Content-Disposition', 'inline; filename="' || p_filename || '"'
ELSE
write_mime_header(
p_conn,
'Content-Disposition', 'attachment; filename="' || p_filename || '"'
END IF;
END IF;
UTL_SMTP.WRITE_DATA(p_conn, UTL_TCP.CRLF);
END begin_attachment;
PROCEDURE binary_attachment(p_conn IN OUT UTL_SMTP.CONNECTION,
p_file_name IN VARCHAR2,
p_mime_type in VARCHAR2)
IS
c_max_line_width CONSTANT PLS_INTEGER DEFAULT 54;
v_amt BINARY_INTEGER := 672 * 3; /* ensures proper format; 2016 */
v_bfile BFILE;
v_file_length PLS_INTEGER;
v_buf RAW(2100);
v_modulo PLS_INTEGER;
v_pieces PLS_INTEGER;
v_file_pos pls_integer := 1;
BEGIN
begin_attachment(
p_conn => p_conn,
p_mime_type => p_mime_type,
p_inline => TRUE,
p_filename => p_file_name,
p_transfer_enc => 'base64');
BEGIN
v_bfile := BFILENAME(p_oracle_directory, p_file_name);
-- Get the size of the file to be attached
v_file_length := DBMS_LOB.GETLENGTH(v_bfile);
-- Calculate the number of pieces the file will be split up into
v_pieces := TRUNC(v_file_length / v_amt);
-- Calculate the remainder after dividing the file into v_amt chunks
v_modulo := MOD(v_file_length, v_amt);
IF (v_modulo <> 0) THEN
-- Since the file does not devide equally
-- we need to go round the loop an extra time to write the last
-- few bytes - so add one to the loop counter.
v_pieces := v_pieces + 1;
END IF;
DBMS_LOB.FILEOPEN(v_bfile, DBMS_LOB.FILE_READONLY);
FOR i IN 1 .. v_pieces LOOP
-- we can read at the beginning of the loop as we have already calculated
-- how many iterations we will take and so do not need to check
-- end of file inside the loop.
v_buf := NULL;
DBMS_LOB.READ(v_bfile, v_amt, v_file_pos, v_buf);
v_file_pos := I * v_amt + 1;
UTL_SMTP.WRITE_RAW_DATA(p_conn, UTL_ENCODE.BASE64_ENCODE(v_buf));
END LOOP;
END;
DBMS_LOB.FILECLOSE(v_bfile);
end_attachment(p_conn => p_conn);
EXCEPTION
WHEN NO_DATA_FOUND THEN
end_attachment(p_conn => p_conn);
DBMS_LOB.FILECLOSE(v_bfile);
END binary_attachment;
-- Main Routine
BEGIN
-- Connect and set up header information:
v_conn:= UTL_SMTP.OPEN_CONNECTION( v_smtp_server, v_smtp_server_port );
UTL_SMTP.HELO( v_conn, v_smtp_server );
UTL_SMTP.MAIL( v_conn, p_from_name );
UTL_SMTP.RCPT( v_conn, p_to_name );
UTL_SMTP.OPEN_DATA ( v_conn );
UTL_SMTP.WRITE_DATA(v_conn, 'Subject: '||p_subject||UTL_TCP.CRLF);
v_mesg:= 'Content-Transfer-Encoding: 7bit' || UTL_TCP.CRLF ||
'Content-Type: multipart/mixed;boundary="DMW.Boundary.605592468"' || UTL_TCP.CRLF ||
'Mime-Version: 1.0' || UTL_TCP.CRLF ||
'--DMW.Boundary.605592468' || UTL_TCP.CRLF ||
'Content-Transfer-Encoding: binary'||UTL_TCP.CRLF||
'Content-Type: text/plain' ||UTL_TCP.CRLF ||
UTL_TCP.CRLF || p_message || UTL_TCP.CRLF ;
UTL_SMTP.write_data(v_conn, 'To: ' || p_to_name || UTL_TCP.crlf);
UTL_SMTP.WRITE_RAW_DATA ( v_conn, UTL_RAW.CAST_TO_RAW(v_mesg) );
-- Add the Attachment
binary_attachment(
p_conn => v_conn,
p_file_name => p_binary_file,
-- Modify the mime type at the beginning of this line depending
-- on the type of file being loaded.
p_mime_type => 'text/plain; name="'||p_binary_file||'"'
-- Send the email
UTL_SMTP.CLOSE_DATA( v_conn );
UTL_SMTP.QUIT( v_conn );
END;
Error
ORA-22288: file or LOB operation GETLENGTH failed
No such file or directory
ORA-06512: at "SYS.DBMS_LOB", line 678
ORA-06512: at "APPS.MAIL_FILES", line 122
ORA-06512: at "APPS.MAIL_FILES", line 179
ORA-06512: at line 2CREATE OR REPLACE PROCEDURE APPS.mail_files (p_from_name VARCHAR2,
p_to_name VARCHAR2,
p_subject VARCHAR2,
p_message VARCHAR2,
p_oracle_directory VARCHAR2,
p_binary_file VARCHAR2)
IS
-- Example procedure to send a mail with an in line attachment
-- encoded in Base64
-- this procedure uses the following nested functions:
-- binary_attachment - calls:
-- begin_attachment - calls:
-- write_boundary
-- write_mime_header
-- end attachment - calls;
-- write_boundary
-- change the following line to refer to your mail server
v_smtp_server VARCHAR2(1000) := 'mail.company.com';
v_smtp_server_port NUMBER := 25;
v_directory_name VARCHAR2(1000);
v_file_name VARCHAR2(1000);
v_mesg VARCHAR2(32767);
v_conn UTL_SMTP.CONNECTION;
PROCEDURE write_mime_header(p_conn in out nocopy utl_smtp.connection,
p_name in varchar2,
p_value in varchar2)
IS
BEGIN
UTL_SMTP.WRITE_RAW_DATA(
p_conn,
UTL_RAW.CAST_TO_RAW( p_name || ': ' || p_value || UTL_TCP.CRLF)
END write_mime_header;
PROCEDURE write_boundary(p_conn IN OUT NOCOPY UTL_SMTP.CONNECTION,
p_last IN BOOLEAN DEFAULT false)
IS
BEGIN
IF (p_last) THEN
UTL_SMTP.WRITE_DATA(p_conn, '--DMW.Boundary.605592468--'||UTL_TCP.CRLF);
ELSE
UTL_SMTP.WRITE_DATA(p_conn, '--DMW.Boundary.605592468'||UTL_TCP.CRLF);
END IF;
END write_boundary;
PROCEDURE end_attachment(p_conn IN OUT NOCOPY UTL_SMTP.CONNECTION,
p_last IN BOOLEAN DEFAULT TRUE)
IS
BEGIN
UTL_SMTP.WRITE_DATA(p_conn, UTL_TCP.CRLF);
IF (p_last) THEN
write_boundary(p_conn, p_last);
END IF;
END end_attachment;
PROCEDURE begin_attachment(p_conn IN OUT NOCOPY UTL_SMTP.CONNECTION,
p_mime_type IN VARCHAR2 DEFAULT 'text/plain',
p_inline IN BOOLEAN DEFAULT false,
p_filename IN VARCHAR2 DEFAULT null,
p_transfer_enc in VARCHAR2 DEFAULT null)
IS
BEGIN
write_boundary(p_conn);
IF (p_transfer_enc IS NOT NULL) THEN
write_mime_header(p_conn, 'Content-Transfer-Encoding',p_transfer_enc);
END IF;
write_mime_header(p_conn, 'Content-Type', p_mime_type);
IF (p_filename IS NOT NULL) THEN
IF (p_inline) THEN
write_mime_header(
p_conn,
'Content-Disposition', 'inline; filename="' || p_filename || '"'
ELSE
write_mime_header(
p_conn,
'Content-Disposition', 'attachment; filename="' || p_filename || '"'
END IF;
END IF;
UTL_SMTP.WRITE_DATA(p_conn, UTL_TCP.CRLF);
END begin_attachment;
PROCEDURE binary_attachment(p_conn IN OUT UTL_SMTP.CONNECTION,
p_file_name IN VARCHAR2,
p_mime_type in VARCHAR2)
IS
c_max_line_width CONSTANT PLS_INTEGER DEFAULT 54;
v_amt BINARY_INTEGER := 672 * 3; /* ensures proper format; 2016 */
v_bfile BFILE;
v_file_length PLS_INTEGER;
v_buf RAW(2100);
v_modulo PLS_INTEGER;
v_pieces PLS_INTEGER;
v_file_pos pls_integer := 1;
BEGIN
begin_attachment(
p_conn => p_conn,
p_mime_type => p_mime_type,
p_inline => TRUE,
p_filename => p_file_name,
p_transfer_enc => 'base64');
BEGIN
v_bfile := BFILENAME(p_oracle_directory, p_file_name);
-- Get the size of the file to be attached
v_file_length := DBMS_LOB.GETLENGTH(v_bfile);
-- Calculate the number of pieces the file will be split up into
v_pieces := TRUNC(v_file_length / v_amt);
-- Calculate the remainder after dividing the file into v_amt chunks
v_modulo := MOD(v_file_length, v_amt);
IF (v_modulo <> 0) THEN
-- Since the file does not devide equally
-- we need to go round the loop an extra time to write the last
-- few bytes - so add one to the loop counter.
v_pieces := v_pieces + 1;
END IF;
DBMS_LOB.FILEOPEN(v_bfile, DBMS_LOB.FILE_READONLY);
FOR i IN 1 .. v_pieces LOOP
-- we can read at the beginning of the loop as we have already calculated
-- how many iterations we will take and so do not need to check
-- end of file inside the loop.
v_buf := NULL;
DBMS_LOB.READ(v_bfile, v_amt, v_file_pos, v_buf);
v_file_pos := I * v_amt + 1;
UTL_SMTP.WRITE_RAW_DATA(p_conn, UTL_ENCODE.BASE64_ENCODE(v_buf));
END LOOP;
END;
DBMS_LOB.FILECLOSE(v_bfile);
end_attachment(p_conn => p_conn);
EXCEPTION
WHEN NO_DATA_FOUND THEN
end_attachment(p_conn => p_conn);
DBMS_LOB.FILECLOSE(v_bfile);
END binary_attachment;
-- Main Routine
BEGIN
-- Connect and set up header information:
v_conn:= UTL_SMTP.OPEN_CONNECTION( v_smtp_server, v_smtp_server_port );
UTL_SMTP.HELO( v_conn, v_smtp_server );
UTL_SMTP.MAIL( v_conn, p_from_name );
UTL_SMTP.RCPT( v_conn, p_to_name );
UTL_SMTP.OPEN_DATA ( v_conn );
UTL_SMTP.WRITE_DATA(v_conn, 'Subject: '||p_subject||UTL_TCP.CRLF);
v_mesg:= 'Content-Transfer-Encoding: 7bit' || UTL_TCP.CRLF ||
'Content-Type: multipart/mixed;boundary="DMW.Boundary.605592468"' || UTL_TCP.CRLF ||
'Mime-Version: 1.0' || UTL_TCP.CRLF ||
'--DMW.Boundary.605592468' || UTL_TCP.CRLF ||
'Content-Transfer-Encoding: binary'||UTL_TCP.CRLF||
'Content-Type: text/plain' ||UTL_TCP.CRLF ||
UTL_TCP.CRLF || p_message || UTL_TCP.CRLF ;
UTL_SMTP.write_data(v_conn, 'To: ' || p_to_name || UTL_TCP.crlf);
UTL_SMTP.WRITE_RAW_DATA ( v_conn, UTL_RAW.CAST_TO_RAW(v_mesg) );
-- Add the Attachment
binary_attachment(
p_conn => v_conn,
p_file_name => p_binary_file,
-- Modify the mime type at the beginning of this line depending
-- on the type of file being loaded.
p_mime_type => 'text/plain; name="'||p_binary_file||'"'
-- Send the email
UTL_SMTP.CLOSE_DATA( v_conn );
UTL_SMTP.QUIT( v_conn );
END;
Edited by: user12879396 on Oct 22, 2012 10:39 AM -
File or LOB operation FILEEXISTs failed
When i executed the sqlcode to check the access i got an error
DECLARE
v_file BFILE := BFILENAME ('DATA_DIR', 'emp.dat');
BEGIN
IF DBMS_LOB.FILEEXISTS (v_file) = 1 THEN
DBMS_OUTPUT.PUT_LINE ('File exists.');
ELSIF DBMS_LOB.FILEEXISTS (v_file) = 0 THEN
DBMS_OUTPUT.PUT_LINE ('File does not exist');
ELSE
DBMS_OUTPUT.PUT_LINE ('Unable to test existence');
END IF;
END;
/ERROR at line 1:
ORA-22288: file or LOB operation FILEEXISTs failed
Permission denied
ORA-06512: at "SYS.DBMS_LOB", line 504
ORA-06512: at line 4
server - Oracle 10.2.0.1.0 Enterprise edition
Server OS- LINUXWhen accessing a file in the file system through the database there are two layers of permission.
Layer 1) The database user needs the right to read (or write) from this directory. Your user probably has this, but you could check it by looking at the data dictionary view all_directories and all_tab_privs.
Layer 2) The database itself needs access to this file. Database itself means the OS process runs with a specific user. Usually this OS-user is called oracle. The user oracle needs access to the OS folder and the file. If the file had been created by another user (e.g. root or user8731258) then somebody must give oracle the right to read this file (including folder).
I guess your problem comes from this second layer. -
XML File in External Table - OS error permission denied.
Hi.
10g R2, Red Hat Linux
I'm using the article (see below, taken from http://www.dbazine.com/olc/olc-articles/scardina1 by Mark Scardina) to create an external table where I'd store my XML file.
So, I
1. Created a directory xmlfile_dir
2. Granted access to needed db user
3. Created the table
CREATE TABLE relayxml_xt (doc CLOB)
ORGANIZATION EXTERNAL
TYPE ORACLE_LOADER
DEFAULT DIRECTORY xmlfile_dir
ACCESS PARAMETERS
FIELDS (lobfn CHAR TERMINATED BY ',')
COLUMN TRANSFORMS (doc FROM lobfile (lobfn))
LOCATION ('xml.dat')
REJECT LIMIT UNLIMITED;
4. mv relay.xml /xmlfile_dir/xml.dat
When I run SELECT * FROM relayxml_xt I get this:
Error starting at line 1 in command:
select * from relayxml_xt
Error report:
SQL Error: ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04063: unable to open log file RELAYXML_XT_28773.log
OS error Permission denied
ORA-06512: at "SYS.ORACLE_LOADER", line 19
29913. 00000 - "error in executing %s callout"
*Cause: The execution of the specified callout caused an error.
*Action: Examine the error messages take appropriate action.
What am I doing wrong?
Thanks,
Using External Tables
Introduced in Oracle9i, Oracle’s external table feature offers a solution to define a table in the database while leaving the data stored outside of the database. Prior to Oracle Database 10g, external tables can be used only as read-only tables. In other words, if you create an external table for XML files, these files can be queries and the table can be joined with other tables. However, no DML operations, such as INSERT, UPDATE, and DELETE, are allowed on the external tables.
Note: In Oracle Database 10g , by using the ORACLE_DATAPUMP driver instead of the default ORACLE_DRIVER, you can write to external tables. In Oracle Database 10g, you can define VARCHAR2 and CLOB columns in external tables to store XML documents. The following example shows how you can create an external table with a CLOB column to store the XML documents. First, you need to create a DIRECTORY to read the data files:
CREATE DIRECTORY data_file_dir AS 'D:\xmlbook\Examples\Chapter9\src\xml';
GRANT READ, WRITE ON DIRECTORY data_file_dir TO demo;
Then, you can use this DIRECTORY to define an external table:
CREATE TABLE customer_xt (doc CLOB)
ORGANIZATION EXTERNAL
TYPE ORACLE_LOADER
DEFAULT DIRECTORY data_file_dir
ACCESS PARAMETERS
FIELDS (lobfn CHAR TERMINATED BY ',')
COLUMN TRANSFORMS (doc FROM lobfile (lobfn))
LOCATION ('xml.dat')
REJECT LIMIT UNLIMITED;
The xml.dat file follows:
customer1.xml
customer2.xml
If you describe the table, you can see the following definition:
SQL> DESC customer_xt;
Name Null? Type
DOC CLOB
Then, you can query the XML document as follows:
SELECT XMLType(doc).extract('/Customer/EMAIL')
FROM customer_xt;
Though the query requires run-time XMLType creation and XPath evaluation, this approach is useful when applications just need a few queries on the XML data and don’t want to upload the XML data into database. In Oracle Database 10g, you cannot create external tables that contain pre-defined XMLType column types.
Message was edited by:
vi2167Your don't have the proper operating system privileges. Be sure that you (=oracle OS user / the OS Linux user that is starting the database) are allowed have read privs on the path and/or file.
for example...
chown -Rf /xxxxxxx/xxxx/etc
ls -l file.xml
file.xml oracle:oinstall rw-rw-rw -
What could cause the following behaviour:
Database 11gR2
declare
l_amt number := dbms_lob.lobmaxsize;
l_dst_loc clob;
l_dst_offset number := 1;
l_lang_ctx number := dbms_lob.default_lang_ctx;
l_src_loc bfile;
l_src_offset number := 1;
l_warning number;
begin
l_src_loc := bfilename('ODS_SERVER_DIRECTORY', '_CIVKD_ASU.CSV');
dbms_lob.createtemporary(l_dst_loc, true);
dbms_lob.fileopen(l_src_loc, dbms_lob.file_readonly);
dbms_lob.loadclobfromfile(l_dst_loc
,l_src_loc
,l_amt
,l_dst_offset
,l_src_offset
,dbms_lob.default_csid
,l_lang_ctx
,l_warning);
commit;
dbms_lob.fileclose(l_src_loc);
dbms_output.put_line(substr(l_dst_loc, 1, 200));
end;
ORA-22288: file or LOB operation FILEOPEN failed
ORA-06512: in "SYS.DBMS_LOB", line 805
ORA-06512: in line 31
22288. 00000 - "file or LOB operation %s failed\n%s"
*Cause: The operation attempted on the file or LOB failed.
*Action: See the next error message in the error stack for more detailed
information. Also, verify that the file or LOB exists and that
the necessary privileges are set for the specified operation. If
the error still persists, report the error to the DBA.However opening and reading the exact same file succeeds when using utl_file.
declare
l_file utl_file.file_type;
l_regel varchar2(4000);
begin
l_file := utl_file.fopen('ODS_SERVER_DIRECTORY', '_CIVKD_ASU.CSV', 'R');
-- Haal de volgende regel op
utl_file.get_line(l_file, l_regel);
dbms_output.put_line(l_regel);
utl_file.fclose_all;
end;So it seems the file is available and accessable by the database.
It's the first time we run into this particular error and it's one of the first 11gR2 instances so maybe there is something 11g specific we don't know about?Some progress made. It turns out the directory object points to a shared drive. It's a windows server and Oracle runs as Local System. I always thought that it was impossible to read anything from a shared drive in this situation. Apparently in some situations you can using utl_file but not usign dbms_lob.
-
Dbms_lob.fileopen failed though utl_file.fgetattr works fine
Hi ,
I am using Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod.
I am working on loading MS .doc into Oracle.
I have created dir using following code:
BEGIN
EXECUTE IMMEDIATE
'CREATE OR REPLACE DIRECTORY TEST_SN1 AS'||
'''\\inecg-sdc11\XYZ_ABC2\DT-AUTOMATION\DUMMY_12LNEW''';
END;
I have verified the existence of file(Status.doc) using utl_file.fgetattr using the following code:
DECLARE
ex BOOLEAN;
flen NUMBER;
bsize NUMBER;
BEGIN
utl_file.fgetattr('TEST_SN1', 'Status.doc', ex, flen, bsize);
IF ex THEN
insert into test_msg values('File Exists');
ELSE
insert into test_msg values('File Does Not Exist');
END IF;
insert into test_msg values('File Length: ' || TO_CHAR(flen));
insert into test_msg values('Block Size: ' || TO_CHAR(bsize));
commit;
END;
the code succuessfully returns the msg 'File exists' along with the file length .
I have also tried opening the file using utl_file and dbmc_lob package+
SQL> DECLARE
2 vInHandle utl_file.file_type;
3 vNewLine VARCHAR2(250);
4 BEGIN
5 vInHandle:= utl_file.fopen('TEST_SN1', 'Status.doc', 'R');
6 utl_file.fclose(vInHandle);
7 END;
8 /
PL/SQL procedure successfully completed.
But the following code still produces error ORA-22288:+
This is what the output was:
SQL> declare
2 l_bfile bfile;
3 begin
4 l_bfile := bfilename( 'TEST_SN1', 'Status.doc' );
5 dbms_lob.fileopen( l_bfile );
6 dbms_lob.fileclose( l_bfile );
7 end;
8 /
declare
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
ORA-06512: at "SYS.DBMS_LOB", line 523
ORA-06512: at line 5
Even though the file exists and Oracle is able to identify the file, I cant figure out what is
stopping my code to open that file.
Please help me to figure out the problem.
For more undertstanding ,You can also refer the my conversation with Tom Kyte at following link:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:636223754581#2815252100346024210
Thanks a million tons!
Regards
Saurabh Nolakha,
BangaloreHi,
Thanks for your quick response.
The file Status.doc which I am trying to access is in remote server at path *\\inecg-sdc11\XYZ_ABC2\DT-AUTOMATION\DUMMY_12LNEW* .Though the path is not mapped to the WINDOWS system where Oracle is installed but I am able to access the file(open and read) from that system.
Do you mean that I need to map the network drive to that system?*
if yes, then why UTL_FILE is working perfectly?*
Also, in my requirement, theres a high possibility that the path(of remote server) may change in future(if mapped).So ,is there any alternative for that?*
Please provide your useful suggestions
Regards
Saurabh Nolakha -
Dbms_lob.FileOpen failed using remote directory in oracle 10g
when i create a directory with the remote shared path like '\\kf-kjyxp\sharepath\temporary' . then in a pl/sql block i use dbms_lob.fileopen to open bfile object , a failure occurs .but the situation does not happen when i use a local diretory like 'd:\sharepath\temporary'.the most puzzling thing is that when i use dbms_lob.FILEISOPEN to check whether i can access the file ,it returns 1 which means succeed . And dbms_lob.GETLENGTH() also returns the right value.
here is the testing code:
declare
pFile bfile;
sDir varchar2(255);
sFileName varchar2(255);
bExist integer := 0;
Amount Integer := 4000;
begin
sDir := 'SRC_PATH';
sFileName := 'ele_onlinedoc.ico';
pFile := bfilename(sDir, sFileName);
--checking file existence
bExist := DBMS_LOB.FILEEXISTS(pFile);
if bExist = 1 then
dbms_output.put_line('File Exist');
else
dbms_output.put_line('File Not Exist');
end if;
--check file size
Amount := dbms_lob.Getlength(pFile);
dbms_output.put_line(TO_CHAR(Amount));
if dbms_lob.FILEISOPEN(pFile) = 1 then
dbms_output.put_line('File is already Opend');
else
dbms_output.put_line('File is closed');
end if;
dbms_lob.fileOpen(pFile,dbms_lob.file_readonly);
dbms_lob.fileclose(pFile);
EXCEPTION
When VALUE_ERROR then
dbms_output.put_line('Exception Value_error');
When OTHERS then
dbms_output.put_line('Exception OTHERS');
dbms_output.put_line(to_char(SQLCODE));
dbms_output.put_line(sQLERRM);
end;
OUTPUT:
File Exist
1078
File is closed
Exception OTHERS
-22288
ORA-22288: file or LOB operation FILEOPEN failed
we can see that file is detected and also we can get the right size(1078 byte) ,
but fail to open the file.
so what`s the problem .
thanks!ORA-22288: file or LOB operation string failed string
Cause: The operation attempted on the file or LOB failed.
Action: See the next error message in the error stack for more detailed information. Also, verify that the file or LOB exists and that the necessary privileges are set for the specified operation. If the error still persists, report the error to the DBA.
Maybe you are looking for
-
Acrobat XI will not access contacts for shared review
I started having this problem yesterday after updating to Acrobat DC and then realizing we weren't ready for DC, so I uninstalled DC and re-installed XI. When I try to send for shared review, collecting on our internal server, as soon as I click on
-
How to retrieve PARTNER_NUMBER from IBRELATION/Partner view (Install bases)
Hi Experts, I've added an enhancement field in IBDETAIL/Header. Within the I-GETTER of this new field I need to retrieve PARTNER_NUMBER of a specific PARTNER_FCT (Partner Function), say '00000002'. IBDETAIL is one of the views in the component IBMAIN
-
How to install the creative suite 5.5 design premium to window 8.1
I am installing the creative suite 5.5 design premium to window 8.1, the installtion progrees reached to 99%, and it stopped and coming with message" close internet explorer" to continue, which I did, but the message keep coming back, Please help.
-
Using iWeb as "journal", not to publish- to iPod?
I would like to keep a "blog journal", but not actually publish my blog. I've made several entries, and now I want to know if I can save this to my Ipod, so that I can view it as a "podcast" or something similar? PowerBook G4, IMac G4 512Ram Mac OS
-
1.1.3: I want my bars back!!!
Apple, ever since updating to 1.1.3, I get 5-7 dropped calls driving along the same interstate which I never had a single dropped call. Around my house before the update, I had 3 bars. Now I get "No Service" or 1 bar, immediately after updating to 1.