Using DBMS_LOB.LOADCLOBFROMFILE

Dear all,
I got some difficulty in trying to use DBMS_LOB.LOADCLOBFROMFILE. Suppose I have this procedure that load an OS file into a CLOB and read, however I keep getting error saying that
ERROR at line 1:
ORA-22275: invalid LOB locator specified
ORA-06512: at "SYS.DBMS_LOB", line 890
ORA-06512: at "HR.SOME_PROC", line 14
ORA-06512: at line 1This is the procedure:
create or replace procedure some_proc is
note_clob clob;
note_bfile bfile;
note_var varchar2(10000);
warning int;
dest_off int:=1;
src_off int:=1;
lang_ctx int:=0;
amount int:=dbms_lob.lobmaxsize;
begin
note_clob:=empty_clob();
note_bfile:=bfilename('TEMP_DIR','note.txt');
dbms_lob.fileopen(note_bfile);
dbms_lob.loadclobfromfile(note_clob,note_bfile,1000,dest_off,src_off,0,lang_ctx,warning);
--dbms_lob.read(note_clob,amount,1,note_var);
dbms_lob.fileclose(note_bfile);
--dbms_output.put_line(note_var);
end some_proc;
/I comment out the part that reads and prints for debugging purpose. Could anybody point me out where did I do wrong on LOADCLOBFROMFILE?
best regards,
Val

Specify below line before loading into target...
DBMS_LOB.CREATETEMPORARY(note_clob,true);

Similar Messages

  • Use of   DBMS_LOB.LoadCLOBFromFile on insert trigger

    We have a system where most of the data is stored on disk as BFILES. However, in certain circumstances I'd like to read some of the files into the database as CLOBS as well. I'd like to do this on record creation and thought the easiest way to do this would be via an trigger on an insert (of the row containing the BFILE) using the DBMS_LOB.LoadCLOBFromFile. However, the (dbms_lob.fileexists(bfile)) returns 0 when executed in the trigger (below). The same command returns 1 after record creation. Can I not reference a BFILE until after its creation?
    create or replace
    TRIGGER "MADAM2"."TRIGGER_CLOB"
    AFTER INSERT ON DATAFILES
    FOR EACH ROW
    declare
    dest_clob   CLOB;
    src_clob    BFILE;
    dst_offset  number := 1;
    src_offset  number := 1;
    lang_ctx    number := DBMS_LOB.DEFAULT_LANG_CTX;
    warning     number;
    begin
    if lower(:new.mime_type) like '%text%' and (:new.doc_size/ (1024 *1024)) < 1 then
    src_clob := :new.path;
    IF (dbms_lob.fileexists(src_clob)) = 1 THEN
    insert into clob_data (fileid, file_text) values (:new.fileid, empty_clob()) returning file_text into dest_clob;
    DBMS_LOB.OPEN(src_clob, DBMS_LOB.LOB_READONLY);
        DBMS_LOB.LoadCLOBFromFile(
              DEST_LOB     => dest_clob
            , SRC_BFILE    => src_clob
            , AMOUNT       => DBMS_LOB.GETLENGTH(src_clob)
            , DEST_OFFSET  => dst_offset
            , SRC_OFFSET   => src_offset
            , BFILE_CSID   => DBMS_LOB.DEFAULT_CSID
            , LANG_CONTEXT => lang_ctx
            , WARNING      => warning
    DBMS_LOB.CLOSE(src_clob);
    end if;
    end if;
    end;

    Please ignore - I think the problem is with some java code which is moving the file after the insert. Apologies.

  • Need explanation about Oracle documentation (DBMS_LOB.LOADCLOBFROMFILE)

    Hello World,
    I try to understand Oracle documentation about DBMS_LOB.LOADCLOBFROMFILE function.
    I am not shure the explanation is written in a very good english,
    but i can't understand a word !!!
    Is anybody could explain me in more simple sentences ??
    DBMS_LOB.LOADCLOBFROMFILE (
    dest_lob IN OUT NOCOPY BLOB,
    src_bfile IN BFILE,
    amount IN INTEGER,
    dest_offset IN OUT INTEGER,
    src_offset IN OUT INTEGER,
    src_csid IN NUMBER,
    lang_context IN OUT INTEGER,
    warning OUT INTEGER);
    Oracle documentation explanation :
    src_csid Character set id of the source (BFILE) file.
    lang_context (IN) Language context, such as shift status, for the current
    load. (OUT) The language context at the time when the
    current load stopped, and what the next load should be using if
    continuing loading from the same source. This information is
    returned to the user so that they can use it for the continuous
    load without losing or misinterpreting any source data. For the
    very first load or if do not care, simply use the default 0. The
    details of this language context is hidden from the user. One
    does not need to know what it is or what’s in it in order to
    make the call
    warning (OUT) Warning message. This indicates something abnormal
    happened during the loading. It may or may not be caused by the
    user’s mistake. The loading is completed as required, and it’s up to the
    user to check the warning message. Currently, the only possible
    warning is the inconvertible character. This happens when the
    character in the source cannot be properly converted to a character in
    destination, and the default replacement character (e.g., ’?’) is used in
    place. The message is defined as warn_inconvertable_char in
    DBMSLOB.

    I am not kidding. I posted the link but I did not check if it were the same source. Really I do not have time to realize it.
    I think you can get a fast answer in SQL & PL/SQL forum.
    Good Luck!
    Joel Pérez

  • Need explanation about DBMS_LOB.LOADCLOBFROMFILE

    Hello World,
    I try to understand Oracle documentation about DBMS_LOB.LOADCLOBFROMFILE function.
    I am not shure the explanation is written in a very good english,
    but i can't understand a word !!!
    Is anybody could explain me in more simple sentences ??
    DBMS_LOB.LOADCLOBFROMFILE (
    dest_lob IN OUT NOCOPY BLOB,
    src_bfile IN BFILE,
    amount IN INTEGER,
    dest_offset IN OUT INTEGER,
    src_offset IN OUT INTEGER,
    src_csid IN NUMBER,
    lang_context IN OUT INTEGER,
    warning OUT INTEGER);
    Oracle documentation explanation :
    src_csid Character set id of the source (BFILE) file.
    lang_context (IN) Language context, such as shift status, for the current
    load. (OUT) The language context at the time when the
    current load stopped, and what the next load should be using if
    continuing loading from the same source. This information is
    returned to the user so that they can use it for the continuous
    load without losing or misinterpreting any source data. For the
    very first load or if do not care, simply use the default 0. The
    details of this language context is hidden from the user. One
    does not need to know what it is or what’s in it in order to
    make the call
    warning (OUT) Warning message. This indicates something abnormal
    happened during the loading. It may or may not be caused by the
    user’s mistake. The loading is completed as required, and it’s up to the
    user to check the warning message. Currently, the only possible
    warning is the inconvertible character. This happens when the
    character in the source cannot be properly converted to a character in
    destination, and the default replacement character (e.g., ’?’) is used in
    place. The message is defined as warn_inconvertable_char in
    DBMSLOB.

    I am not kidding. I posted the link but I did not check if it were the same source. Really I do not have time to realize it.
    I think you can get a fast answer in SQL & PL/SQL forum.
    Good Luck!
    Joel Pérez

  • Need help in using dbms_lob.read

    I need to upload a file into an Oracle table into a Blob column. The file name along with the file contents are all in one BLOB column.
    Once that is done I need to read from the file and extract the file contents and load it into a staging table.
    File being uploaded is a *.CSV* file.
    E.g. Of the .CSV file is: ABC.csv file and its contents will look like:
    1,Hello,Nisha
    2,Hi,Ravi
    3,Bye, Rahul
    Etc…..
    Therefore the table containing the BLOB column will contain:
    File Creation_date
    ABC.csv 09/11/2009
    How can I read a file from the BLOB column and upload into a staging table?
    Final Staging table should look like:
    Record Number Greet Name
    1 Hello Nisha
    2 Hi Ravi
    3 Bye Rahul
    I think I am suppose to use dbms_lob.read, but I am not really sure how to use it. If there is any script, kindly mail me the same.
    Thanks....

    Nisha,
    Check this example (test) and see if it can be any help. I have utl_file and sqlldr
    First Method -- I loaded alert.log successfully and you can imagine how big this file can be (5MB in my test case)
    create table t1clob
    ( clob_text clob);
    CREATE OR REPLACE DIRECTORY DIR AS '/path_to_csv_file/;
    DECLARE
       clob_data   CLOB;
       clob_file   BFILE;
    BEGIN
       INSERT INTO t1clob
       VALUES (EMPTY_CLOB ())
       RETURNING clob_text INTO clob_data;
       clob_file   := BFILENAME ('DIR', ABC.csv');
       DBMS_LOB.fileopen (clob_file);
       DBMS_LOB.loadfromfile (clob_data,
                              clob_file,
                              DBMS_LOB.getlength (clob_file)
       DBMS_LOB.fileclose (clob_file);
       COMMIT;
    END;Second Method: Use of Sqlldr
    Example of controlfile
    LOAD DATA
    INFILE alert.log "STR '|\n'"
    REPLACE INTO  table t1clob
       clob_text char(30000000)
    )Hope this helps.

  • Error while creating AW using DBMS_LOB with XML..

    Hi All,
    I am trying to create AW using DBMS_LOB package with XML,
    while creating AW,i am facing the following error.find the code also below :
    declare
    xml_awcreate_clob clob;
    xml_awcreate_st varchar2(4000);
    begin
    DBMS_LOB.CREATETEMPORARY(xml_awcreate_clob,TRUE);
    dbms_lob.open(xml_awcreate_clob, DBMS_LOB.LOB_READWRITE);
    dbms_lob.writeappend(xml_awcreate_clob, 48, '<?xml version = ''1.0'' encoding = ''UTF-8'' ?>');
    dbms_lob.writeappend(xml_awcreate_clob, 43, '');
    dbms_lob.writeappend(xml_awcreate_clob, 63, '<AWXML version = ''1.0'' timestamp = ''Mon Feb 11 13:29:11 2002'' >');
    dbms_lob.writeappend(xml_awcreate_clob, 15, '<AWXML.content>');
    dbms_lob.writeappend(xml_awcreate_clob, 25, ' <Create Id="Action41">');
    dbms_lob.writeappend(xml_awcreate_clob, 19, ' <ActiveObject >');
    dbms_lob.writeappend(xml_awcreate_clob, 163, ' <AW Name="NEW_XML_AW" LongName="NEW_XML_AW" ShortName="NEW_XML_AW" PluralName="NEW_XML_AW" Id="NEW_XML.AW"/>');
    dbms_lob.writeappend(xml_awcreate_clob, 19, ' </ActiveObject>');
    dbms_lob.writeappend(xml_awcreate_clob, 11, ' </Create>');
    dbms_lob.writeappend(xml_awcreate_clob, 16, '</AWXML.content>');
    dbms_lob.writeappend(xml_awcreate_clob, 8, '</AWXML>');
    dbms_lob.close(xml_awcreate_clob);
    xml_awcreate_st := sys.interactionExecute(xml_awcreate_clob);
    end;
    ORA-21560: argument 2 is null, invalid, or out of range
    ORA-06512: at "SYS.DBMS_LOB", line 833
    ORA-06512: at line 12
    Any idea or thought on this would be appreciable.
    Thanks in advance.
    Anwar

    Did you change any of the text in the lob write statements ?
    I believe you get this error if you increase the number of characters without increasing the 1st argument which looks as though it represents the number of characters

  • Error while converting CLOB to varchar using DBMS_LOB.SUBSTR() in Oracle11g

    Hi
    Whenever I am using DBMS_LOB.SUBSTR(columnname,4000,1) package for a clob column in a simple Select Query, the following error is thrown for Oracle 11g version.
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 1.
    Please find the installation details of the database and the character set
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE     11.2.0.1.0     Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET AL32UTF8
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_RDBMS_VERSION 11.2.0.1.0
    It is working fine if I reduce from 4000 to 3500 . But I want to use 4000.
    Please let me know if any solution

    you are using a multibyte character set:
    NLS_CHARACTERSET AL32UTF8
    so each character takes between 1 and 4 bytes of storage.
    a varchar2(4000) column can only hold 4000 BYTES. Regardless of the character set - varchar2 is limited to 4000 bytes.
    In a single byte character set, that is 4000 characters as a character = a byte
    In your character set, a varchar2(4000) can hold somewhere between 1000 and 4000 characters - depending on what the characters are.
    So, you must have some CLOB whose first 4000 characters include at least one "more than one byte" character. That won't fit into a varchar2(4000)
    Your approach of backing off the substr size is reasonable (and you'll need to remember that in your application - end users can type in as little as 1000 characters and get an error about the column being too small!) as it reduces the number of BYTES to be belong 4000.

  • How to insert 10 files from a directory to database,can i use dbms_lob??

    Hii
    I want to load 10files in my local drive into a table...how to do this.I'm able to do this individually using dbms_lob.loadfromfile and bfil but ,I want to copy all the files i that drive at time to my table...Is there any way to do this..?

    Okay... Here is some sample code that will help you store the files in binary format into db tables.
    create table t_blob(bid integer, blbdata blob);
    select * from t_blob;
    create or replace directory ext_tab_dir as 'C:\Oracle\ExtTab_Dir';
    grant read, write on directory ext_tab_dir to priya;
    declare
          src_file bfile;
          dest_file blob;
          len_file pls_integer;
    begin
          src_file:=bfilename('EXT_TAB_DIR','XML.doc');
          insert into t_blob values(1,empty_blob()) returning blbdata into dest_file;
          select blbdata into dest_file
            from t_blob
           where bid=1 for update;
          dbms_lob.fileopen(src_file,dbms_lob.file_readonly);
          len_file:=dbms_lob.getlength(src_file);
          dbms_output.put_line(len_file);
          dbms_lob.loadfromfile(dest_file,src_file,len_file);
          update t_blob
             set blbdata = dest_file
           where bid = 1;
          dbms_lob.fileclose(src_file);
    end;
    /I haven't used the wrap utility yet, so not much hands on with it. I guess the wrap utility at the OS level. Not sure if it will work at SQL prompt.

  • Using dbms_lob

    Hi,
    I have a need to open blob_content files from wwv_document$ and read/print them in a portlet. Can i do that using dbms_blob?. If so can somebody guide me the steps to follow? Else is there any other way sicne the files are really huge and i need to read from DB only.
    Thanks in advance
    null

    A lot of the answer to your question depends on what is in your BLOB and what you are trying to do with it. If you can post more details about your end goals.. and what is being stored in your documents (MS Word Docs, Random Binary Files, Images, Text files... etc) I can post specific details about what statements to use.
    In general you can use DBMS_LOB.READ to pull information directly out of a BLOB. See the Packages Reference documentation for details about the syntax. When you need to pass the BLOB locator, that is just what you get when you do a simple select on the BLOB_CONTENT column in the WWDOC_DOCUMENT$ table.

  • Using DBMS_LOB.COPY - (ORA-22275)

    Hi All,
    I need to copy BLOB value from one table to another.
    For that i am using DBMS_LOB.COPY.
    I am not sure if this is the right approach. If not, can someone help me out.
    Mentioned below is my sample procedure:
    CREATE OR REPLACE PROCEDURE INS_UPD_BLOB
    i_ID number,
    o_OutputStatus OUT NUMBER,
    o_OutputMessage OUT VARCHAR2
    as
    v_blob_data_d blob;
    v_blob_data_s blob;
    amt INTEGER := 4000;
    begin
    select BLOB_DATA
    into v_blob_data_d
    from blob_test_dest -- My Destination Table
    where id = i_ID
    for update;
    select BLOB_DATA
    into v_blob_data_s
    from blob_test -- My Source Table
    where id = i_ID;
    DBMS_LOB.COPY(v_blob_data_d, v_blob_data_s, amt);
    o_OutputStatus := 0;
    o_OutputMessage := 'SUCCESS';
    EXCEPTION
    WHEN OTHERS THEN
    o_OutputStatus := -1;
    o_OutputMessage := 'Procedure ins_upd_blob Failed at step no:- '||v_ErrorFlag|| ' SQL ERROR:- '||SUBSTR(SQLERRM,1,100);
    END;
    After execution i am getting following error:
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
    Thanks,
    Srikanth

    how about using merge instead of dbms_lob package?
    CREATE OR REPLACE PROCEDURE INS_UPD_BLOB
    i_ID number,
    o_OutputStatus OUT NUMBER,
    o_OutputMessage OUT VARCHAR2)
    as
    v_blob_data_d blob;
    v_blob_data_s blob;
    amt INTEGER := 4000;
    begin
    merge into blob_test_dest b1
    using (select id, blob_data from blob_test) b2
    on (b1.id = i_id and b1.id = b2.id)
    when not matched then insert(b1.id, b1.blob_data) values(b2.id,b2.blob_data)
    when matched then update set b1.blob_data = b2.blob_data;
    END;
    /

  • Using dbms_lob in trigger 10gR2

    Hello,
    I'm trying to read from a clob using dbms_lob in my trigger and assigning the value to a variable. My trigger is compiling fine, but it doesn't seem to be working.
    I'm using 10gR2. Am I misunderstanding how to read from/assign to a variable in a trigger?
    Line from trigger code:
    v_serial_start := dbms_lob.instr(:new.search_xml_clob,'serial=') + 8;
    Thanks,
    Mimi

    Here's a quick example that works fine for me....
    ME_XE?create table clobberin_tyme
      2  (
      3     some_column    number,
      4     variable_value number default 0,
      5     some_clob      clob default empty_clob()
      6  );
    Table created.
    Elapsed: 00:00:03.98
    ME_XE?
    ME_XE?
    ME_XE?create or replace trigger clobberin_tymeT01
      2  before insert or update on clobberin_tyme
      3  for each row
      4  declare
      5     v_serial_start    number;
      6  begin
      7
      8     v_serial_start       := dbms_lob.instr(:new.some_clob,'serial=') + 8;
      9
    10     :new.variable_value  := v_serial_start;
    11
    12  end;
    13  /
    Trigger created.
    Elapsed: 00:00:02.62
    ME_XE?
    ME_XE?
    ME_XE?insert into clobberin_tyme (some_column) values (1);
    1 row created.
    Elapsed: 00:00:00.31
    ME_XE?
    ME_XE?select * from clobberin_tyme;
           SOME_COLUMN     VARIABLE_VALUE SOME_CLOB
                     1                  8
    1 row selected.
    Elapsed: 00:00:00.17
    ME_XE?
    ME_XE?update clobberin_tyme
      2     set   some_column = 2,
      3           some_clob = 'hello world serial= coco puffs, i am cucu for them';
    1 row updated.
    Elapsed: 00:00:00.25
    ME_XE?
    ME_XE?select * from clobberin_tyme;
           SOME_COLUMN     VARIABLE_VALUE SOME_CLOB
                     2                 21 hello world serial= coco puffs, i am cucu for them
    1 row selected.
    Elapsed: 00:00:00.01

  • Using dbms_lob append to insert text how do you insert a new line inbetween

    DBMS_LOB.APPEND (P_TEXT,'* Operator Phone,');
    ---- inbetween I need to insert new I am using DBMS_LOB.APPEND (P_TEXT,CHR(10)); IS there amy better method?
    DBMS_LOB.APPEND (P_TEXT,'* Operator Email Address,');

    Sorry if the question was not clear ---
    Lets say in the folowing example every write append needs to start on a new line followed by text. How do we do that?
    Do we add another writeappend(cvar,22, chr(10)); inbetween?
    dbms_lob.writeappend(cvar, 19, '<root><book><title>');
    dbms_lob.writeappend(cvar, length(r.title), r.title);
    dbms_lob.writeappend(cvar, 14, '</title><desc>');
    dbms_lob.writeappend(cvar, length(r.description), r.description);
    dbms_lob.writeappend(cvar, 27, '</desc></book><author_name>');
    dbms_lob.writeappend(cvar, length(r.author_name), r.author_name);
    dbms_lob.writeappend(cvar, 21, '</author_name></root>');
    Edited by: user521218 on May 7, 2009 12:34 PM

  • Use dbms_lob.loadfromfile to handle chinese character

    Hello,
    I have a database with NLS_LANG=TRADITIONAL CHINESE_HONG KONG.ZHT16BIG5
    There is a table with clob type column.
    I've tried to use dbms_lob.loadfromfile to load file content into the clob type column.
    But the result is that no matter the file is english or chinese character, the column's content will become "monster".
    Is there any method to solve this problem ?
    Can anyone help ?
    Rgds,
    Edward
    null

    Hi, it's me again.
    I just want to share my experience and hope that it can help someone and someone can help me !
    I've created a database with UTF8 as my character set.
    With session's character set = UTF8, when I tried to use dbms_lob.loadfromfile to load data into clob column from a file with chinese character content. What has been stored is "monster" character. I know that it's because bfile is with binary type and will not do character set conversion when loadfromfile is being used.
    I've tried the other way, I use dbms_lob.read to read the file and use utl_raw to convert it to UTF8 character set and store it in a varchar2. It works !
    But what I want is to store the chinese character into the clob column.
    I've tried to use the following option but still fail :
    - convert (it's seems that has no effect)
    - utl_raw.translate (it always get oracle error, I've use this as : utl_raw.translate(RAW, 'UTF8', 'UTF8'))
    - utl_raw.convert
    Hope that some have experience can help me !
    Rgds,
    Edward
    null

  • Error in using DBMS_LOB Package

    Hi,
    I am attaching a PDF File through a database procedure as shown below
    create or replace procedure load_document(document_id in number, filename IN varchar2, doc_desc IN VARCHAR2, doc_type IN VARCHAR2) as
    f_lob bfile;
    b_lob blob;
    --document_name varchar2(30);
    --mime_type varchar2(30);
    document_name oea_documents.document_name%TYPE;
    mime_type oea_documents.document_mime_type%TYPE;
    dot_pos number;
    v_file_type VARCHAR2(10);
    begin
    -- Find the position of the dot ('.') located in the filename
    dot_pos := instr(filename,'.');
    -- Get the filename without extension and use it as image name
    document_name := substr(filename,1,dot_pos-1);
    -- Build the mime type . Retrieve the file extension and add it to 'image/'
    v_file_type := SUBSTR( filename, dot_pos+1, Length(Filename) );
    IF ( UPPER(v_file_type) IN ('JPG','JPEG','TIF','TIFF','GIF') ) THEN
    mime_type := 'image/'||substr( filename , dot_pos+1 , length(filename) );
    ELSIF ( UPPER(v_file_type) = 'PDF' ) THEN
    mime_type := 'application/pdf';
    ELSIF ( UPPER(v_file_type) = 'DOC' )THEN
    mime_type := 'application/msword';
    ELSIF ( UPPER( v_file_type) = 'XLS') THEN
    mime_type := 'application/ms-excel';
    ELSE
    mime_type := 'image/'||substr( filename , dot_pos+1 , length(filename) );
    END IF;
    insert into oea_documents (document_id,
    document_name,
    document_mime_type,
    document,
    document_description,
    document_type
    values(document_id, document_name, mime_type, empty_blob(),doc_desc,doc_type) return document into b_lob;
    -- /!\ Directory name has to be UpperCase !
    f_lob := bfilename('FILE_LOAD',filename);
    o_dset_test('5');
    dbms_lob.fileopen(f_lob,dbms_lob.file_readonly);
    o_dset_test('6');
    dbms_lob.loadfromfile(b_lob,f_lob,dbms_lob.getlength(f_lob) );
    dbms_lob.fileclose(f_lob);
    commit;
    end;
    FILE_LOAD is a folder on the database server(unix).
    I have also tried to give the full path on the unix databse server instead of FILE_LOAD directory but then it gives error ora-22285.
    while executing this procedure I am getting the error ora-22288(Invalid file or directory).
    But this occurs randomly
    For instance i tried to attach a pdf file with the name cross.pdf ,it gave me the above error and when i renamed the file as Cross.pdf it attached successfully.
    The error comes whilke executing the statement dbms_lob.fileopen(f_lob,dbms_lob.file_readonly);
    Please guide on the above issue.

    Hi,
    Welcome to the forum!
    user1356624 wrote:
    f_lob := bfilename('FILE_LOAD',filename);
    FILE_LOAD is a folder on the database server(unix).
    I have also tried to give the full path on the unix databse server instead of FILE_LOAD directory but then it gives error ora-22285.The first argument to BFILENAME is the name of a directory object, as found in the directory_name column of all_directories. That is not the same thing as a folder name, which is found in the directory_path column of all_directories. Look up [CREATE DIRECTORY|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_5007.htm#sthref6211] in the SQL Language manual for a description of Oracle's directory objects.
    If you have problems with this, post the results of
    SELECT  *
    FROM    all_directories;It might also be useful to see the Oracle "CREATE DIRECTORY" command that was used.
    As you probably noticed, this site compresses white space by default.
    When you post code or results on this site, type these 6 characters:
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    Edited by: Frank Kulash on Aug 10, 2009 3:35 PM
    Added link.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • PDF file created from Oracle Report is created wrongly using dbms_lob

    Hi,
    Please help. It is very urgent.
    I am using Oracle Developer 10gR2, Oracle Report 10.1.2 on Windows 2000.
    I would like to attach the PDF file created by Oracle Report to the Notification sent from Workflow.
    I use the following package procedure in my Workflow.
    procedure Create_File_Attachment (document_id   in varchar2, display_type  in varchar2,
                                                                                         document      in out blob, document_type in out varchar2)
    is
         l_itemtype          varchar2(100);
         l_itemkey           varchar2(100);
         l_output_directory  varchar2(30);
         l_filename          varchar2(255);
         src_loc             bfile;
         bdoc                blob;
         src_offset          number := 1;
         dst_offset          number := 1;
         amount              number;
    begin
         l_itemtype := substr(document_id, 1, instr(document_id, ':') - 1);
         l_itemkey := substr(document_id, instr(document_id, ':') + 1, length(document_id) - 2);
         l_output_directory := 'USR_TMP_DIR';
         l_filename := Wf_Engine.GetItemAttrText(l_itemtype, l_itemkey, 'ATR_FILENAME');
         src_loc := bfilename(l_output_directory,l_filename);
         dbms_lob.createTemporary(bdoc, FALSE, dbms_lob.call);
         dbms_lob.fileopen(src_loc, dbms_lob.file_readonly);
         dbms_lob.loadblobfromfile(bdoc,src_loc,dbms_lob.lobmaxsize,src_offset,dst_offset);
         dbms_lob.fileclose(src_loc);
         amount := dbms_lob.getLength(bdoc);
         dbms_lob.copy(document,bdoc,amount,1,1);
         document_type := 'application/pdf; name=attach.pdf';
    end Create_File_Attachment;Oracle Report created the PDF file correctly (original.pdf).
    I tried to attach the PDF into my Workflow.
    I can see the file is attached (attach.pdf), but it cannot be opened.
    The Adobe shows : 'A drawing error occured.' each time I open the attachment.
    I compare the original.pdf and the attach.pdf
    However, there is one specific difference
    - in original.pdf, the line started with '.' (single period)
    in attach.pdf, the line is started with '..' (two periods)
    Thus the attachment cannot be opened.
    After I delete the period, it can be opened.
    Question:
    - Has someone ever succeed in attaching the PDF created from Report?
    - Are the codes above is wrong?
    - Or perhaps the DBMS_LOB.LOADBLOBFROMFILE always double the single period on front of the line?
    - Is there any solution on this?
    Note:
    I have succeed in attaching PDF files unless the PDF created by the Report.
    Sorry for the long post.
    Please help. It is very urgent.
    Any help is appreciated.
    Many thanks,
    Buntoro

    Hi,
    Please help. It is very urgent.
    I am using Oracle Developer 10gR2, Oracle Report 10.1.2 on Windows 2000.
    I would like to attach the PDF file created by Oracle Report to the Notification sent from Workflow.
    I use the following package procedure in my Workflow.
    procedure Create_File_Attachment (document_id   in varchar2, display_type  in varchar2,
                                                                                         document      in out blob, document_type in out varchar2)
    is
         l_itemtype          varchar2(100);
         l_itemkey           varchar2(100);
         l_output_directory  varchar2(30);
         l_filename          varchar2(255);
         src_loc             bfile;
         bdoc                blob;
         src_offset          number := 1;
         dst_offset          number := 1;
         amount              number;
    begin
         l_itemtype := substr(document_id, 1, instr(document_id, ':') - 1);
         l_itemkey := substr(document_id, instr(document_id, ':') + 1, length(document_id) - 2);
         l_output_directory := 'USR_TMP_DIR';
         l_filename := Wf_Engine.GetItemAttrText(l_itemtype, l_itemkey, 'ATR_FILENAME');
         src_loc := bfilename(l_output_directory,l_filename);
         dbms_lob.createTemporary(bdoc, FALSE, dbms_lob.call);
         dbms_lob.fileopen(src_loc, dbms_lob.file_readonly);
         dbms_lob.loadblobfromfile(bdoc,src_loc,dbms_lob.lobmaxsize,src_offset,dst_offset);
         dbms_lob.fileclose(src_loc);
         amount := dbms_lob.getLength(bdoc);
         dbms_lob.copy(document,bdoc,amount,1,1);
         document_type := 'application/pdf; name=attach.pdf';
    end Create_File_Attachment;Oracle Report created the PDF file correctly (original.pdf).
    I tried to attach the PDF into my Workflow.
    I can see the file is attached (attach.pdf), but it cannot be opened.
    The Adobe shows : 'A drawing error occured.' each time I open the attachment.
    I compare the original.pdf and the attach.pdf
    However, there is one specific difference
    - in original.pdf, the line started with '.' (single period)
    in attach.pdf, the line is started with '..' (two periods)
    Thus the attachment cannot be opened.
    After I delete the period, it can be opened.
    Question:
    - Has someone ever succeed in attaching the PDF created from Report?
    - Are the codes above is wrong?
    - Or perhaps the DBMS_LOB.LOADBLOBFROMFILE always double the single period on front of the line?
    - Is there any solution on this?
    Note:
    I have succeed in attaching PDF files unless the PDF created by the Report.
    Sorry for the long post.
    Please help. It is very urgent.
    Any help is appreciated.
    Many thanks,
    Buntoro

Maybe you are looking for

  • Why does my external hard drive disappear?

    I've tried USB2, Firewire 800, and network connection (Time Capsule). None of the drives stays connected long enough to get a backup done. The drive just disappears and the backup stops. i tried this with a brand new drive from Western Digital, and a

  • Second License installation issue

    I am trying to install my second license for CS5 and it is telling me that I am already booked up on two computers. This is impossible as I only had one computer until yesterday. Adobe, how does this get fixed? I don't want to deactivate the account

  • Execute immediate 'alter session set current_schema = ' failed in PL/SQL

    Hi I am trying to run EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = TEST ' ; in a pl/sql block but it is failing.Can anyone update me on this. CREATE OR REPLACE PROCEDURE test3 IS A_COUNT NUMBER(15); BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET

  • Changing Valuation type & serial no. during STO

    Dear Experts , I have one issue , kindly help me to resolve it. I am doing stock transfer order from plant 1 to plant2, the material to be transfered from plant 1 has say valuation type  x , serial 001, can I maintain valuation type y & serial no. 00

  • OS crashed and cannot switch to console model when logout from gnome

    after update gnome to 3.2,  when I logout login account or switch user with gnome. the os dead. I have to reset pc to reboot it. should this isskue relate to gnome update?