ORA-22288

I've a procedure to load a file into a table:
CREATE OR REPLACE PROCEDURE load_xml (p_dir IN VARCHAR2,
p_filename IN VARCHAR2) AS
l_bfile BFILE := BFILENAME(p_dir, p_filename);
l_clob CLOB;
BEGIN
DBMS_LOB.createtemporary (l_clob, TRUE);
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
DBMS_LOB.loadfromfile(l_clob, l_bfile, DBMS_LOB.getlength(l_bfile));
DBMS_LOB.fileclose(l_bfile);
INSERT INTO xml_tab (
id,
filename,
xml
VALUES (
xml_tab_seq.NEXTVAL,
p_filename,
XMLTYPE.createXML(l_clob)
COMMIT;
DBMS_LOB.freetemporary (l_clob);
END;
But i always get this error message:
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
The system can't find the path
the path is 'C:\orant\tools\web60\temp' and i can find it!
I don't know why i get this error message!
With best regards
Nicole

Nicole,
Since operating systems differ in their file and directory nameing conventions, Oracle abstracts these details with a logical directory object. You create a logical directory command with the command
create directory directoryname as 'os-specific-dirname';
You then use the logical directory name directoryname when working with files inside PL/SQL.
Then grant read permissions to the directory to the user of the procedure.
grant read on direcotry directoryname to username;
Check your directory entry to ensure it is pointing to a valid file location on the server.
select directory_name, directory_path from all_directories;
One guess is the directory entry was created without quotes around it, and the uppercase/lowercase is the issue.

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

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

  • Dbms_lob.fileopen gives ORA-22288. Can open the same file with utl_file.

    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.

  • 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

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

  • Simon, why do I get an OrdImage.setProperties() exception ORA-22288

    Hi Simon;
    I've debugged a problem with the ImageExample to the point where I'm convinced one cannot call setProperties indirectly as the example code shows. SetProperties can only be called during a load - for example imgObj.LoadFromFile
    The example from OTN sample code shows a sample method:
    public void setPropertiesExample(OracleConnection con)
    try
    int index = 0;
    Statement s = con.createStatement();
    OracleResultSet rs =
    (OracleResultSet)s.executeQuery("select * from ordimagetab where id = 5 for update");
    while(rs.next())
    index = rs.getInt(1);
    OrdImage imgObj = (OrdImage) rs.getCustomDatum(2, OrdImage.getFactory());
    imgObj.setProperties();
    System.out.println("set Properties called");
    if(imgObj.checkProperties())
    System.out.println("checkProperties called");
    System.out.println("setProperties successful");
    System.out.println("checkProperties successful");
    System.out.println("successful");
    else
    System.out.println("checkProperties called");
    System.out.println("setProperties not successful");
    System.out.println("checkProperties successful");
    OraclePreparedStatement stmt1 =
    (OraclePreparedStatement) con.prepareCall("update ordimagetab set image = ? where id = " + index);
    stmt1.setCustomDatum(1,imgObj);
    stmt1.execute();
    stmt1.close() ;
    rs.close();
    s.close();
    catch(Exception e)
    System.out.println("exception raised " + e);
    }No matter how many times I set this example or create something similar I get this error when I do something like:
    ImageExample ie = new ImageExample();
    con = ie.connect();
    ie.setPropertiesExample(con);
    exception raised java.sql.SQLException: ORA-22288: file or LOB operation FILEOPEN failed
    No such file or directory
    ORA-06512: at "ORDSYS.ORDIMG_PKG", line 418
    ORA-06512: at "ORDSYS.ORDIMAGE", line 25
    ORA-06512: at line 2
    I noticed the only way to avoid this problem is to load the image immediately prior to the setproperties call...like:
    OrdImage imgObj = (OrdImage) rs.getCustomDatum(2, OrdImage.getFactory());
    imgObj.loadDataFromFile("imgdemo.dat");
    imgObj.setProperties();
    imgObj.getDataInFile("fileexample.dat");Here I get setproperties to work, but I need to change a lot of code to load images in this form...
    I am using the constructors provided and the functions you provided some time back - so I do not believe initialization is the issue here. Any ideas what might be wrong here??

    Hi Chris,
    There are a number of configuration and/or setup problems that can
    cause this error. But first, it might be worth describing at a higher
    level what is going on here.
    By default an interMedia object can store or 'reference' data in one
    of 3 ways:
    - local: the data is stored locally in the BLOB, the local flag is
    set to 1 to indicate this.
    - FILE: the source type is set to FILE, which indicates the data is
    stored in a directory of which the server is aware and to
    which the user/schema has been granted access. The source
    location specifies the database server directory name, which
    will be upper case unless you created a mixed-case name with
    the CREATE DIRECTORY command. The source name specifies the
    file name, which is case sensitive on Unix platforms.
    - HTTP: the source type is set to HTTP, which indicates the data is
    accessed via a web server. The source location is the domain,
    port and path and the source name is the item name.
    If you instantiate an ORDIMAGE object using something like:
    CREATE OR REPLACE DIRECTORY MY_IMAGE_DIR AS 'c:\myphotos';
    INSERT INTO MY_IMAGES VALUES
    ( 1, ORDSYS.ORDIMAGE.INIT( 'FILE', 'MY_IMAGE_DIR', 'photo1.jpg' );then the setProperties method is going to try to open photo1.jpg in
    the directory known to the database as MY_IMAGE_DIR. This can fail
    with "ORA-22288: file or LOB operation FILEOPEN failed; No such file
    or directory" for a number of reasons:
    [list]
    [*]The directory MY_IMAGE_DIR was never created using CREATE DIRECTORY
    [*]The user was not granted read access to MY_IMAGE_DIR
    [*]The directory c:\myphotos doesn't exist
    [*]The file photo1.jpg doesn't exist in c:\myphotos
    [list]
    Bear in mind that, essentially, everything is happening at the server,
    all the client is doing is causing the setProperties method of the
    ORDIMAGE type to be invoked at the server, which reads the image file,
    which must be accessible to the server. Assuming everything to be OK,
    then the properties will be read from the image and stored in the
    object. Of course, since BFILEs are writable, you can't operate on
    this image to scale, crop or convert it, for example.
    However, in your case, you're hitting one of the problems listed above.
    Bear in mind, there are others. For example, although you might be able
    to access an image on a shared network drive of some sort, doesn't mean
    to say that the database server can do so. This is a common problem on
    NT. When logged in as you, you might be able to mount a network drive
    and access an image file on that drive. However, that access is being
    performed with your NT credentials and access rights. The database server
    doesn't have the same credentials and access rights and in all likelyhood
    will NOT be able to access the same file. Of course, the same situation
    can occur in Unix land with NFS.
    Contrast all that with what happens when a client application calls
    loadDataFromFile. In this case, the client is reading image data from
    a file that is local to the client (which could easily be on a
    different machine than the server) and writing that image data
    directly into the database as the contents of the BLOB. Therefore,
    assuming the image format is recognized, setProperties is going to
    succeed because the data is in the database, not external to it.
    To sum up: setProperties can be called on an image when stored as a FILE.
    However, the database server has to be able to access the file and the
    directory in which it is stored. The reason it works when you call
    loadDataFromFile is that the data is written to the BLOB in the database,
    so the database has access.
    Hope that makes sense,
    Simon
    null

  • FILEOPEN failed:ORA-22288 and LFI-00108

    File or LOB operation FILEOPEN failed?
    My configuration of the Intermedia Cartridge respond VALID and INSTALLED, and my path and file is OK, whats this error messages: ORA-22288 and LFI-00108 ?
    - Sorry my english...
    null

    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.

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

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

  • ORA-22288 (another one)

    Good afternoon,
    When I run this code, the procedure completes successfully:
    declare
    ftyp utl_file.file_type;
    begin
    ftyp := utl_file.fopen('TOC_DOCS','DefRpt.pdf','r',32767);
    end;
    When I run this code, I get 'ORA-22288: file or LOB operation FILEOPEN failed'
    Access is denied.
    declare
    v_bfile BFILE;
    v_blob BLOB;
    BEGIN
    v_bfile := BFILENAME('TOC_DOCS', 'DefRpt.pdf');
    Dbms_Lob.Fileopen(v_bfile, Dbms_Lob.File_Readonly);
    end;
    Same filename, same login, same database, same everything that I can see. I've checked the permissions on the windows directory that holds the file, I've checked the file itself (I've copied, moved, renamed, deleted, re-copied.... I have full access to the windows drive/directory where the file resides.)
    What am I missing?
    Thanks,
    Don.

    I don't have any test instances available at the moment to try this, but since pdf is considered a binary file, did you try opening in rb rather than r ?

  • 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

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

  • BFileSample:  Error while selecting BFILE Locator java.sql.SQLException: ORA-22288:

    Hello, i have compiled and executed the BFileSample java standalone successfully. I am wondering how to use this in a production environment where there may be hundreds of image files stored categorically over a period of years? is it possible to use the BFILE_TABLE in conjunction w/ other tables e.g. use the BFILE_TABLE as fk to some table to query the oracle instance for select image files based on say some category: time, location and other relations? i have tried select * on BFILE_TABLE but i get the following errors:
    SQL> select BFILE_COLUMN from BFILE_TABLE;
    SP2-0678: Column or attribute type can not be displayed by SQL*Plus
    Is the BFILE_TABLE usefull in anyway outside of the current implementation? thanx, david.

    Hi David,
    BFILE's are also called external LOB's, since data is stored in OS files outside the database and use reference semantics.
    Apart from conventional secondary storage devices such as hard disks, BFILEs may also be located on tertiary block storage devices such as CD-ROMs, PhotoCDs and DVDs.
    A table having BFILE column can be used like any other table, you can reference any column and have fk relationships. The only disadvantage of BFILE's is that backup doesn't happen automatically (since reference is only stored), the OS has to take care of backups of BFILE data.
    LOB's(BLOB, CLOB, BFILE) cannot be viewed in SQL Plus using selects, you can either get length or any associated attributes of these datatypes.
    example:
    select dbms_lob.getlength( BFILE_COLUMN) from bfile_table;
    I would suggest BFILE when you don't want to stress your tablespace(CLOB and BLOB sit on tablespace) and also when data need not be replicated .i.e if you copy a BFILE record, data is not copied, only the reference is copied(both reference will point to same file), but in case of CLOB and BLOB complete data is duplicated.
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96591/adl12bfl.htm#99013
    Hope this helps.
    Elango.

Maybe you are looking for

  • Installing iSync conduit for HotSync 3.2.1

    Hello, I got a Powerbook G4 with OS X.4.8 I've just bought a Palm T|X with Palm OS 5.4.9. I've dowloaded the last package Palm Desktop 4.2.1 for Mac with HotSync Manager 3.2.1 Hotsync functions well with Palm Desktop. In iSync, I go to "Device / Acti

  • How to handle the events of business object (BAPI)

    Hi, How to register to BAPI event and handle? For example, for a business object 'inv', there is an event as 'created'. I want to insert entry in a z table when an inv is created. I assume that the 'created' event is triggered when an inv is created.

  • Displaying Heirarchical Data

    Is there a way to query heirarchical data so that it shows it's heirarchical structure but is also ordered within its heirarchical structure. e.g. you can query the SCOTT.EMP table using: SELECT empno, ename, hiredate FROM emp CONNECT BY mgr = PRIOR

  • NVSRUN (nVision-Report)  - nVision process going in the error status

    NVSRUN (nVision-Report) - nVision process going in the error status for all nVision reports submitted from the web. All nVision reports submitted online from the web are failing. Need to create new run control ID? How to do that for NVSRUN process? =

  • Desktop items gone...or hidden..?

    After some attempts to run DiskWarrior from one HD to another I was asked for privileges and I must have done something wrong. My desktops items are not there (don't appear on desktop) and I can't find them anywhere on my HDs. But... tried to copy 2