Inserting image to table...ORA-22288: file or LOB operation FILEOPEN failed

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

Similar Messages

  • 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 (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?
    Thanks

    Know 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

  • 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!

  • 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 City

    Hi 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

  • 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.

  • 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,
    Frank

    when 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?

  • Unable to Open Workflow Notification attachment Throwing Error-"ORA-20002: 3240: Error -22288 - ORA-22288: file or LOB operation FILEOPEN failed No such file or directory in 'PLSQLBLOB"

    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 2

    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;
    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- LINUX

    When 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.

  • Inserting image into table

    hi,
    i m create table, then create procedure, procedure is successfully compile, but when i m trying to insert image into table it error out.
    for inserting image i go with
    EXECUTE insert_image_file(1,'C:\sunset.jpg');
    sunset.jpg is image which i want to insert in table, and which is present on 'c drive'.
    when execute the following error are shown
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 635
    ORA-06512: at "SCOTT.INSERT_IMAGE_FILE", line 26
    ORA-06512: at line 1
    how to solve it.
    regards
    prashant

    Prashant wrote:
    CREATE OR REPLACE PROCEDURE insert_image_file (p_id NUMBER, p_image_name IN VARCHAR2)
    ...snipped...Not very nice code... why create an empty image row, then lock it (it is already locked by the uncommitted insert statement), and then update it again? Not very efficient or sensible.
    image is on local machine.When a row is created on the server from user input on some PC, who supplied that input? Who read the user's keyboard input on that PC to obtain the values for the columns for the row to create?
    Did PL/SQL read the keyboard of that remote PC? Of course not. The client program on that PC read the keyboard input. It then made a client call to the Oracle server. It supplied the data entered via the keyboard by the user to the Oracle server (using a PL/SQL call or using a SQL statement call to Oracle).
    Now why would a local image data on that PC be treated any differently than the keyboard data on that PC? How can you expect PL/SQL code running on the Oracle server, to read that image data from the remote PC when the same PL/SQL code is incapable of reading keyboard input from that very same PC?
    You need to review your understanding of client-server and how it pertains to using Oracle within client-server architecture.

  • Insert image into table

    Please let me know how to insert images to table using SQLDeveloper?

    Some history...
    SQL Developer 1.2.1 actually does support loading BLOBs and it has an internal viewer that can display some, but not all, common extensions (e.g., jpeg images will display, but not flv - flash). The 1.2.1 UI is different than the 3.0/3.1 UI Jim describes in his blog post: double clicking on a BLOB cell in the Table Data tab causes it to display a "..." at the right-side of the cell. Clicking that takes you to the Edit Value dialog where Load/Save/View capability resides.
    External editor support was in place at least by 2.1, but large BLOBs seem rather slow to load. Improved performance and the current UI appeared at least by 3.0, including the Pencil icon and the hyperlinks.
    -Gary

  • Error in inserting images into table

    Hi All,
    I am trying to insert images into a table.
    Followed these steps:
    CREATE TABLE XX_DEMO_IMG_TBL
    file_id      NUMBER(5),
    file_name      VARCHAR2(30),
    file_data      BLOB
    LOAD DATA
    INFILE *
    REPLACE
    INTO TABLE XX_DEMO_IMG_TBL
    FIELDS TERMINATED BY ','
    file_id INTEGER(5),
    file_name FILLER CHAR(30),
    file_data LOBFILE (file_name) TERMINATED BY EOF
    BEGINDATA
    1,c:\1.txt
    used sqlldr cmd
    Got the following error:
    *ecord 1: Rejected - Error on table XX_DEMO_IMG_TBL.
    ORA-01460: unimplemented or unreasonable conversion requested*
    I am using SQLPlus: Release 10.2.0.3.0 -*
    Can any one please guide where am i going wrong ?
    Thanks,
    Saritha

    Thanks for your time.
    I got a solution for this, I modified my control file like this..
    LOAD DATA
    INFILE *
    REPLACE
    INTO TABLE SCOTT.XX_DEMO_IMG_TBL
    FIELDS TERMINATED BY ','
    file_id ,
    file_name ,
    file_data LOBFILE (file_name) TERMINATED BY EOF
    BEGINDATA
    1,c:\Users\SariRavi\Desktop\logo.gif
    and it worked.
    Thanks,
    Saritha

  • How to insert image into table and to in Oracle 9i intermedia?

    Mr Lawrence,
    I want to ask something:
    I use Oracle 9i intermedia
    If i use this script:
    CREATE TABLE images (
    file_name VARCHAR2(100) NOT NULL,
    image ORDSYS.OrdImage
    then
    CREATE OR REPLACE DIRECTORY imgdir AS 'd:/data';
    then
    INSERT INTO images (file_name, image)
    VALUES ('tree', ORDSYS.ORDImage.init('file','imgdir','tree.jpg' ));
    I put tree.jpg in directory d:/data in my hard drive.
    Is my tree.jpg file had already get in to my images table?
    I'm little confuse, because when i check my table with this script:
    select file_name, i.image.getWidth() from images i;
    it's show that my i.image.getWidth() for file_name tree is empty.. that mean my tree.jpg doesn't get in to my table.. am i correct?
    N also i want to ask how to display to screen all of my image from images table?
    Is it posible Oracle 9i intermedia to support display image from table?
    How?
    thanks Mr Lawrence

    -- First step would be to create a directory in oracle and map it to the folder where your image resides.
    create directory image_dir as *'c:\image_dir';*
    Then you would have to use a procedure to insert the image in your table. SO first create a table to hold the image. Note that you have to use a BLOB to insert the image.
    CREATE TABLE test_image
    ID NUMBER,
    image_filename VARCHAR2(50),
    image BLOB
    Now let's write the procedure to insert the image in the table above.
    CREATE OR REPLACE PROCEDURE insert_image_file (p_id 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 a NULL record to lock
    INSERT INTO temp_image
    (ID, image_name, image
    VALUES (p_id, p_image_name, EMPTY_BLOB ()
    RETURNING image
    INTO dst_file;
    -- lock record
    SELECT image
    INTO dst_file
    FROM temp_image
    WHERE ID = p_id AND image_name = p_image_name
    FOR UPDATE;
    -- open the file
    DBMS_LOB.fileopen (src_file, DBMS_LOB.file_readonly);
    -- determine length
    lgh_file := DBMS_LOB.getlength (src_file);
    -- read the file
    DBMS_LOB.loadfromfile (dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE temp_image
    SET image = dst_file
    WHERE ID = p_id AND image_name = p_image_name;
    -- close file
    DBMS_LOB.fileclose (src_file);
    END insert_image_file;
    Now execute the procedure to insert the image.
    EXECUTE insert_image_file(1,'test_image.jpg');
    Thanks,
    Aparna

Maybe you are looking for

  • JRC (upg. to CR4E) - Report w Subreport - Oracle DB -  Null Pointer Excepti

    Hi We have a Crystal Designer/Developer Version 11.5.10.1263. We develop reports using this. Most of the reports have SQL Command mode design with JNDI/JDBC connection. It gets deployed with our Web application. And during runtime, when users access

  • I just got the DKU-2 USB Data Cable

    but i have a problem my phone is Nokia 6111 but when i put the cd in and the software loads it shows picturs of phones to click on but doesn't show the 6111. Does it matter? I clicked on any phone picture and installed the usb cable but when i'n on t

  • Is there anyway to use Mic Office10 on my Macbook OSX lion

    Is there any way i can use Mic office 10 on my Macbook OSX lion

  • PDF to Ebook

    Hello! My name Diana and I want to know the especification more detailed to PDFs are encryption because I readed the manual and I have many question for example said "Form both old and new formats"  but and PDF  than 35MB  weight doesn't work very we

  • Redeveloping a client's existing BC website

    I have see the thread about partners redeveloping sites but for a client - I have a couple who want rebuilds. If I use a brand new portal to do this in (which would be much easier to work with), will Business Catalyst then move over the balance of th