ORA-22285

HI,
I am having a problem in pl/sql. I am creating a directory object as----"create or replace directory photo_folder as 'D:\IMAGE';
Then i have made a table like this----create table test(id varchar2(10),image bfile);
After that when i am trying to insert an image into the table like this---insert into test values('1',bfilename('photo_folder','1.jpg')); it says....1 row created.
but when i am trying to query the table--select id,dbms_lob.getlength(image)"image size" from test;
it gives error-----ORA-22285: non-existent directory or file for GETLENGTH operation
ORA-06512: at "SYS.DBMS_LOB",line 566.
What am i doing wrong. Plz help me to resolve this.
regards,
Argha

Yes exactly that's the reason!!!
SQL> create table t(no number, data bfile)
  2  /
Table created.
SQL> create directory my_data_dir as 'e:\oracle\log_files\utl_akivanew'
  2  /
Directory created.
SQL> insert into t values(1,bfilename('my_data_dir','oracle.gif'))
  2  /
1 row created.
SQL> select no, dbms_lob.getlength(data) from t
  2  /
select no, dbms_lob.getlength(data) from t
ERROR at line 1:
ORA-22285: non-existent directory or file for GETLENGTH operation
ORA-06512: at "SYS.DBMS_LOB", line 566Now see
SQL> insert into t values(1,bfilename('MY_DATA_DIR','oracle.gif'))
  2  /
1 row created.
SQL> select no, dbms_lob.getlength(data) from t
  2  /
        NO DBMS_LOB.GETLENGTH(DATA)
         1                     2059Thanks,
Karthick.

Similar Messages

  • ORA-22285 Loadclobfromfile and definer rights

    I've create a directory D in schema A.
    Schema A has read permissions on the directory.
    Created a stored procedure X that reads a clob from a file in this directory.
    Running the procedure as user A works ok.
    Granted execute rights on procedure X to user B
    When user B tries to run procedure X I get error: ORA-22285: non-existent directory or file for FILEOPEN operation.
    It turns out I have to grant B read permission on the directory D.
    I don't understand why this is necessary. Procedure X runs with definer rights by default.
    Maybe someone can shed a bit of light on this ?

    // ACEs where r u ?!Oh don't Re: Needs another simple fix ! (Its been over 24hrs, nobody tried! Strange) Alex, I thought you were one of the good guys.
    Anyway, I expect a lot of the Aces are in the air right now, heading for 'Frisco.
    To your question:
    which one of the two above is the best one?It depends. Is John a developer or a user? If John is a developer then the DBA should grant him privileges explicitly. If John is a user then it is appropriate to use a role for his privileges and thus use the AUTHID CURRENT_USER approach.
    Note, I think this example is flawed because I would not expect a user to have a procedure which dynamically creates a table. Certainly I wouldn't expect John as a user to be creating procedures or to know about invoker rights. But the same model applies if the privilege is say SELECT access on another user's tables.
    the question that emerges is why do we have roles anyway if we can't truly rely on them (?)In my view ROLES are intended for managing users rather than developers. Generally I think this means granting table privileges to roles but not system privileges (although CREATE SESSION is an obvious exception). We should not use Roles for managing the privileges of developers, or for application owner accounts come to that. If the account has a schema it probably should have individually granted system privileges; as with most generalisations there is a grey area.
    Cheers, APC
    Message was edited by: inserting the crucial NOT that makes the sentence make sense
    APC

  • ORA-22285 - non-existent directory or file for FILEOPEN operation

    Hello
    I want to insert the xmldata from a xmlfile to the a table, with this scirpt:
    #!/bin/sh
    set -x
    for i in `find . -name "dspevent*.xml"| awk -F"/" '{print $NF}'`
    do
    echo $i
    fname_old=$i
    fname_neu=`ls $i | awk '{print "OK_"$0}'`
    cat $i | sed 's/aps://g' >$fname_neu
    echo $fname_neu
    rm $i
    #insert_xml $fname_neu
    INSERT_XML=`sqlplus -s username/passwort@database <<EOF
    INSERT INTO event_xml (name,
    dtsysl,
    hrsysl,
    dtcptl,
    nusesi,
    dsp_step,
    dsp_state,
    bat_class,
    bat_program,
    bat_seqi,
    bat_state)
    SELECT *
    FROM XMLTABLE (
    'Operations/Event'
    PASSING xmltype (BFILENAME ('EVENT_DIR', '$fname_neu'),
    NLS_CHARSET_ID ('CHAR_CS'))
    COLUMNS name VARCHAR (40) PATH 'name',
    dtsysl DATE PATH 'dtsysl',
    hrsysl NUMBER PATH 'hrsysl',
    dtcptl DATE PATH 'dtcptl',
    nusesi NUMBER PATH 'nusesi',
    dsp_step VARCHAR (40) PATH 'DSP/step',
    dsp_state VARCHAR (40) PATH 'DSP/state',
    bat_class VARCHAR (40) PATH 'BAT/class',
    bat_program VARCHAR (40) PATH 'BAT/program',
    bat_seqi NUMBER PATH 'BAT/seqi',
    bat_state VARCHAR (40) PATH 'BAT/state');
    EOF
    `
    done
    But the problem is, that I have always this error message:
    ORA-22285 -> non-existent directory or file for FILEOPEN operation
    I'd create a direcotrie and over utl_file.fopen I can write a file to this directorie, but this works over the path, not over the directory name. the utl_file_dir parameter was also set to the correct path. Whats wrong or how can I debug this problem?
    thanks.
    roger

    - the name of the directory is correct.
    - how can I check, that the user can use the directory?
    - in this logfile you can see that, the file name will replace correctly:
    ./dspevent.sh
    + awk -F/ {print $NF}
    + find . -name dspevent*.xml
    + echo dspevent_db_20110503030448_10641.xml
    dspevent_db_20110503030448_10641.xml
    fname_old=dspevent_db_20110503030448_10641.xml
    + awk {print "OK_"$0}
    + ls dspevent_db_20110503030448_10641.xml
    fname_neu=OK_dspevent_db_20110503030448_10641.xml
    + sed s/aps://g
    + cat dspevent_db_20110503030448_10641.xml
    + echo OK_dspevent_db_20110503030448_10641.xml
    OK_dspevent_db_20110503030448_10641.xml
    + rm dspevent_db_20110503030448_10641.xml
    + sqlplus -s username/passwort@db
    INSERT INTO event_xml (name,
    dtsysl,
    hrsysl,
    dtcptl,
    nusesi,
    dsp_step,
    dsp_state,
    bat_class,
    bat_program,
    bat_seqi,
    bat_state)
    SELECT *
    FROM XMLTABLE (
    'Operations/Event'
    PASSING xmltype (BFILENAME ('EVENT_DIR', 'OK_dspevent_db_20110503030448_10641.xml'),
    NLS_CHARSET_ID ('CHAR_CS'))
    COLUMNS name VARCHAR (40) PATH 'name',
    dtsysl DATE PATH 'dtsysl',
    hrsysl NUMBER PATH 'hrsysl',
    dtcptl DATE PATH 'dtcptl',
    nusesi NUMBER PATH 'nusesi',
    dsp_step VARCHAR (40) PATH 'DSP/step',
    dsp_state VARCHAR (40) PATH 'DSP/state',
    bat_class VARCHAR (40) PATH 'BAT/class',
    bat_program VARCHAR (40) PATH 'BAT/program',
    bat_seqi NUMBER PATH 'BAT/seqi',
    bat_state VARCHAR (40) PATH 'BAT/state');
    INSERT_XML= PASSING xmltype (BFILENAME ('EVENT_DIR', 'OK_dspevent_db_20110503030448_10641.xml'),
    ERROR at line 15:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.XMLTYPE", line 296
    ORA-06512: at line 1
    + echo dspevent_db_20110502190712_10641.xml
    dspevent_db_20110502190712_10641.xml

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

  • Can't open file while loading CLOB

    Following the examples on this forum, I've written the following:
    CREATE DIRECTORY doc_dir AS 'C:\Documents' ;
    DECLARE
    source_file BFILE := BFILENAME('doc_dir', 'test_document.doc');
    dest_lob CLOB;
    amount INTEGER := 4000;
    BEGIN
    DBMS_LOB.FILEOPEN(source_file, DBMS_LOB.FILE_READONLY) ;
    DBMS_LOB.LOADFROMFILE(dest_lob, source_file, amount) ;
    COMMIT ;
    DBMS_LOB.FILECLOSE(source_file) ;
    END ;
    This fails with the following message in SQLPlus:
    DECLARE
    ERROR at line 1:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 523
    ORA-06512: at line 9
    Both the directory and file are definitely there, so what gives? Any ideas?

    tell you what take this code.
    SQL> create table test_data(id number, clob_data clob)
      2  /
    Table created.
    SQL>
    SQL> declare
      2    l_clob      clob ;
      3    file_loc    bfile := bfilename('DIR_SWF', 'test2.glt2fe_expanded_cs');
      4    l_lang_ctx  number := 0;
      5    l_Warning   number :=0;
      6    l_src       number :=1;
      7    l_dest      number :=1;
      8  begin
      9      dbms_lob.createtemporary(l_clob, TRUE);
    10      dbms_lob.fileopen(file_loc, dbms_lob.file_readonly);
    11      dbms_lob.loadclobfromfile(l_clob, file_loc, dbms_lob.lobmaxsize, l_Src,l_dest, 0,l_lang_ctx, l_Warning);
    12      dbms_output.put_line(dbms_lob.getlength(l_clob));
    13      insert into test_Data values(1,l_clob);
    14      dbms_lob.fileclose(file_loc);
    15  end;
    16  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select dbms_lob.getlength(clob_data) from test_data
      2  /
    DBMS_LOB.GETLENGTH(CLOB_DATA)                                                  
                             6727                                                   change the filename if it is not correct in the below code.
    create table test_data(id number, clob_data clob)
    declare
      l_clob      clob ;
      file_loc    bfile := bfilename('DOC_DIR', 'test_documents.txt');
      l_lang_ctx  number := 0;
      l_Warning   number :=0;
      l_src       number :=1;
      l_dest      number :=1;
    begin
        dbms_lob.createtemporary(l_clob, TRUE);
        dbms_lob.fileopen(file_loc, dbms_lob.file_readonly);
        dbms_lob.loadclobfromfile(l_clob, file_loc, dbms_lob.lobmaxsize, l_Src,l_dest, 0,l_lang_ctx, l_Warning);
        dbms_output.put_line(dbms_lob.getlength(l_clob));
        insert into test_Data values(1,l_clob);
        dbms_lob.fileclose(file_loc);
    end;
    select dbms_lob.getlength(clob_data) from test_data
    /

  • Error in .dbf to table loading

    Hi all ,
    I am loading a .dbf file into a table.I took code from google for it.But I dnt know why its not working when I am running code.
    error coming as below..can anyone help me ..
    BEGIN
    EXPRESS.DBF2ORA.LOAD_TABLE ( ‘DATA_201′, ‘SAL_HEAD.DBF’, ‘dbf_tab_pc’, NULL, false );
    END;
    error is ....
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at “EXPRESS.DBF2ORA”, line 414
    ORA-06512: at line 2
    package code is ...
    package body dbase_pkg
    as
    -- Might have to change on your platform!!!
    -- Controls the byte order of binary integers read in
    -- from the dbase file
    BIG_ENDIAN constant boolean default TRUE;
    type dbf_header is RECORD
    version varchar2(25), -- dBASE version number
    year int, -- 1 byte int year, add to 1900
    month int, -- 1 byte month
    day int, -- 1 byte day
    no_records int, -- number of records in file,
    -- 4 byte int
    hdr_len int, -- length of header, 2 byte int
    rec_len int, -- number of bytes in record,
    -- 2 byte int
    no_fields int -- number of fields
    type field_descriptor is RECORD
    name varchar2(11),
    type char(1),
    length int, -- 1 byte length
    decimals int -- 1 byte scale
    type field_descriptor_array
    is table of
    field_descriptor index by binary_integer;
    type rowArray
    is table of
    varchar2(4000) index by binary_integer;
    g_cursor binary_integer default dbms_sql.open_cursor;
    -- Function to convert a binary unsigned integer
    -- into a PLSQL number
    function to_int( p_data in varchar2 ) return number
    is
    l_number number default 0;
    l_bytes number default length(p_data);
    begin
    if (big_endian)
    then
    for i in 1 .. l_bytes loop
    l_number := l_number +
    ascii(substr(p_data,i,1)) *
    power(2,8*(i-1));
    end loop;
    else
    for i in 1 .. l_bytes loop
    l_number := l_number +
    ascii(substr(p_data,l_bytes-i+1,1)) *
    power(2,8*(i-1));
    end loop;
    end if;
    return l_number;
    end;
    -- Routine to parse the DBASE header record, can get
    -- all of the details of the contents of a dbase file from
    -- this header
    procedure get_header
    (p_bfile in bfile,
    p_bfile_offset in out NUMBER,
    p_hdr in out dbf_header,
    p_flds in out field_descriptor_array )
    is
    l_data varchar2(100);
    l_hdr_size number default 32;
    l_field_desc_size number default 32;
    l_flds field_descriptor_array;
    begin
    p_flds := l_flds;
    l_data := utl_raw.cast_to_varchar2(
    dbms_lob.substr( p_bfile,
    l_hdr_size,
    p_bfile_offset ) );
    p_bfile_offset := p_bfile_offset + l_hdr_size;
    p_hdr.version := ascii( substr( l_data, 1, 1 ) );
    p_hdr.year := 1900 + ascii( substr( l_data, 2, 1 ) );
    p_hdr.month := ascii( substr( l_data, 3, 1 ) );
    p_hdr.day := ascii( substr( l_data, 4, 1 ) );
    p_hdr.no_records := to_int( substr( l_data, 5, 4 ) );
    p_hdr.hdr_len := to_int( substr( l_data, 9, 2 ) );
    p_hdr.rec_len := to_int( substr( l_data, 11, 2 ) );
    p_hdr.no_fields := trunc( (p_hdr.hdr_len - l_hdr_size)/
    l_field_desc_size );
    for i in 1 .. p_hdr.no_fields
    loop
    l_data := utl_raw.cast_to_varchar2(
    dbms_lob.substr( p_bfile,
    l_field_desc_size,
    p_bfile_offset ));
    p_bfile_offset := p_bfile_offset + l_field_desc_size;
    p_flds(i).name := rtrim(substr(l_data,1,11),chr(0));
    p_flds(i).type := substr( l_data, 12, 1 );
    p_flds(i).length := ascii( substr( l_data, 17, 1 ) );
    p_flds(i).decimals := ascii(substr(l_data,18,1) );
    end loop;
    p_bfile_offset := p_bfile_offset +
    mod( p_hdr.hdr_len - l_hdr_size,
    l_field_desc_size );
    end;
    function build_insert
    ( p_tname in varchar2,
    p_cnames in varchar2,
    p_flds in field_descriptor_array ) return varchar2
    is
    l_insert_statement long;
    begin
    l_insert_statement := 'insert into ' || p_tname || '(';
    if ( p_cnames is NOT NULL )
    then
    l_insert_statement := l_insert_statement ||
    p_cnames || ') values (';
    else
    for i in 1 .. p_flds.count
    loop
    if ( i <> 1 )
    then
    l_insert_statement := l_insert_statement||',';
    end if;
    l_insert_statement := l_insert_statement ||
    '"'|| p_flds(i).name || '"';
    end loop;
    l_insert_statement := l_insert_statement ||
    ') values (';
    end if;
    for i in 1 .. p_flds.count
    loop
    if ( i <> 1 )
    then
    l_insert_statement := l_insert_statement || ',';
    end if;
    if ( p_flds(i).type = 'D' )
    then
    l_insert_statement := l_insert_statement ||
    'to_date(:bv' || i || ',''yyyymmdd'' )';
    else
    l_insert_statement := l_insert_statement ||
    ':bv' || i;
    end if;
    end loop;
    l_insert_statement := l_insert_statement || ')';
    return l_insert_statement;
    end;
    function get_row
    ( p_bfile in bfile,
    p_bfile_offset in out number,
    p_hdr in dbf_header,
    p_flds in field_descriptor_array ) return rowArray
    is
    l_data varchar2(4000);
    l_row rowArray;
    l_n number default 2;
    begin
    l_data := utl_raw.cast_to_varchar2(
    dbms_lob.substr( p_bfile,
    p_hdr.rec_len,
    p_bfile_offset ) );
    p_bfile_offset := p_bfile_offset + p_hdr.rec_len;
    l_row(0) := substr( l_data, 1, 1 );
    for i in 1 .. p_hdr.no_fields loop
    l_row(i) := rtrim(ltrim(substr( l_data,
    l_n,
    p_flds(i).length ) ));
    if ( p_flds(i).type = 'F' and l_row(i) = '.' )
    then
    l_row(i) := NULL;
    end if;
    l_n := l_n + p_flds(i).length;
    end loop;
    return l_row;
    end get_row;
    procedure show( p_hdr in dbf_header,
    p_flds in field_descriptor_array,
    p_tname in varchar2,
    p_cnames in varchar2,
    p_bfile in bfile )
    is
    l_sep varchar2(1) default ',';
    procedure p(p_str in varchar2)
    is
    l_str long default p_str;
    begin
    while( l_str is not null )
    loop
    dbms_output.put_line( substr(l_str,1,250) );
    l_str := substr( l_str, 251 );
    end loop;
    end;
    begin
    p( 'Sizeof DBASE File: ' || dbms_lob.getlength(p_bfile) );
    p( 'DBASE Header Information: ' );
    p( chr(9)||'Version = ' || p_hdr.version );
    p( chr(9)||'Year = ' || p_hdr.year );
    p( chr(9)||'Month = ' || p_hdr.month );
    p( chr(9)||'Day = ' || p_hdr.day );
    p( chr(9)||'#Recs = ' || p_hdr.no_records);
    p( chr(9)||'Hdr Len = ' || p_hdr.hdr_len );
    p( chr(9)||'Rec Len = ' || p_hdr.rec_len );
    p( chr(9)||'#Fields = ' || p_hdr.no_fields );
    p( chr(10)||'Data Fields:' );
    for i in 1 .. p_hdr.no_fields
    loop
    p( 'Field(' || i || ') '
    || 'Name = "' || p_flds(i).name || '", '
    || 'Type = ' || p_flds(i).Type || ', '
    || 'Len = ' || p_flds(i).length || ', '
    || 'Scale= ' || p_flds(i).decimals );
    end loop;
    p( chr(10) || 'Insert We would use:' );
    p( build_insert( p_tname, p_cnames, p_flds ) );
    p( chr(10) || 'Table that could be created to hold data:');
    p( 'create table ' || p_tname );
    p( '(' );
    for i in 1 .. p_hdr.no_fields
    loop
    if ( i = p_hdr.no_fields ) then l_sep := ')'; end if;
    dbms_output.put
    ( chr(9) || '"' || p_flds(i).name || '" ');
    if ( p_flds(i).type = 'D' ) then
    p( 'date' || l_sep );
    elsif ( p_flds(i).type = 'F' ) then
    p( 'float' || l_sep );
    elsif ( p_flds(i).type = 'N' ) then
    if ( p_flds(i).decimals > 0 )
    then
    p( 'number('||p_flds(i).length||','||
    p_flds(i).decimals || ')' ||
    l_sep );
    else
    p( 'number('||p_flds(i).length||')'||l_sep );
    end if;
    else
    p( 'varchar2(' || p_flds(i).length || ')'||l_sep);
    end if;
    end loop;
    p( '/' );
    end;
    procedure load_Table( p_dir in varchar2,
    p_file in varchar2,
    p_tname in varchar2,
    p_cnames in varchar2 default NULL,
    p_show in boolean default FALSE )
    is
    l_bfile bfile;
    l_offset number default 1;
    l_hdr dbf_header;
    l_flds field_descriptor_array;
    l_row rowArray;
    begin
    l_bfile := bfilename( p_dir, p_file );
    dbms_lob.fileopen( l_bfile );
    get_header( l_bfile, l_offset, l_hdr, l_flds );
    if ( p_show )
    then
    show( l_hdr, l_flds, p_tname, p_cnames, l_bfile );
    else
    dbms_sql.parse( g_cursor,
    build_insert(p_tname,p_cnames,l_flds),
    dbms_sql.native );
    for i in 1 .. l_hdr.no_records loop
    l_row := get_row( l_bfile,
    l_offset,
    l_hdr,
    l_flds );
    if ( l_row(0) <> '*' ) -- deleted record
    then
    for i in 1..l_hdr.no_fields loop
    dbms_sql.bind_variable( g_cursor,
    ':bv'||i,
    l_row(i),
    4000 );
    end loop;
    if ( dbms_sql.execute( g_cursor ) <> 1 )
    then
    raise_application_error( -20001,
    'Insert failed ' || sqlerrm );
    end if;
    end if;
    end loop;
    end if;
    dbms_lob.fileclose( l_bfile );
    exception
    when others then
    if ( dbms_lob.isopen( l_bfile ) > 0 ) then
    dbms_lob.fileclose( l_bfile );
    end if;
    RAISE;
    end;
    end;
    i think i am doing mistake in creating and using directory ..direct me plz..

    Hi all ,
    I am loading a .dbf file into a table.I took code from google for it.But I dnt know why its not working when I am running code.
    error coming as below..can anyone help me ..
    BEGIN
    EXPRESS.DBF2ORA.LOAD_TABLE ( ‘DATA_201′, ‘SAL_HEAD.DBF’, ‘dbf_tab_pc’, NULL, false );
    END;
    error is ....
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at “EXPRESS.DBF2ORA”, line 414
    ORA-06512: at line 2
    package code is ...
    package body dbase_pkg
    as
    -- Might have to change on your platform!!!
    -- Controls the byte order of binary integers read in
    -- from the dbase file
    BIG_ENDIAN constant boolean default TRUE;
    type dbf_header is RECORD
    version varchar2(25), -- dBASE version number
    year int, -- 1 byte int year, add to 1900
    month int, -- 1 byte month
    day int, -- 1 byte day
    no_records int, -- number of records in file,
    -- 4 byte int
    hdr_len int, -- length of header, 2 byte int
    rec_len int, -- number of bytes in record,
    -- 2 byte int
    no_fields int -- number of fields
    type field_descriptor is RECORD
    name varchar2(11),
    type char(1),
    length int, -- 1 byte length
    decimals int -- 1 byte scale
    type field_descriptor_array
    is table of
    field_descriptor index by binary_integer;
    type rowArray
    is table of
    varchar2(4000) index by binary_integer;
    g_cursor binary_integer default dbms_sql.open_cursor;
    -- Function to convert a binary unsigned integer
    -- into a PLSQL number
    function to_int( p_data in varchar2 ) return number
    is
    l_number number default 0;
    l_bytes number default length(p_data);
    begin
    if (big_endian)
    then
    for i in 1 .. l_bytes loop
    l_number := l_number +
    ascii(substr(p_data,i,1)) *
    power(2,8*(i-1));
    end loop;
    else
    for i in 1 .. l_bytes loop
    l_number := l_number +
    ascii(substr(p_data,l_bytes-i+1,1)) *
    power(2,8*(i-1));
    end loop;
    end if;
    return l_number;
    end;
    -- Routine to parse the DBASE header record, can get
    -- all of the details of the contents of a dbase file from
    -- this header
    procedure get_header
    (p_bfile in bfile,
    p_bfile_offset in out NUMBER,
    p_hdr in out dbf_header,
    p_flds in out field_descriptor_array )
    is
    l_data varchar2(100);
    l_hdr_size number default 32;
    l_field_desc_size number default 32;
    l_flds field_descriptor_array;
    begin
    p_flds := l_flds;
    l_data := utl_raw.cast_to_varchar2(
    dbms_lob.substr( p_bfile,
    l_hdr_size,
    p_bfile_offset ) );
    p_bfile_offset := p_bfile_offset + l_hdr_size;
    p_hdr.version := ascii( substr( l_data, 1, 1 ) );
    p_hdr.year := 1900 + ascii( substr( l_data, 2, 1 ) );
    p_hdr.month := ascii( substr( l_data, 3, 1 ) );
    p_hdr.day := ascii( substr( l_data, 4, 1 ) );
    p_hdr.no_records := to_int( substr( l_data, 5, 4 ) );
    p_hdr.hdr_len := to_int( substr( l_data, 9, 2 ) );
    p_hdr.rec_len := to_int( substr( l_data, 11, 2 ) );
    p_hdr.no_fields := trunc( (p_hdr.hdr_len - l_hdr_size)/
    l_field_desc_size );
    for i in 1 .. p_hdr.no_fields
    loop
    l_data := utl_raw.cast_to_varchar2(
    dbms_lob.substr( p_bfile,
    l_field_desc_size,
    p_bfile_offset ));
    p_bfile_offset := p_bfile_offset + l_field_desc_size;
    p_flds(i).name := rtrim(substr(l_data,1,11),chr(0));
    p_flds(i).type := substr( l_data, 12, 1 );
    p_flds(i).length := ascii( substr( l_data, 17, 1 ) );
    p_flds(i).decimals := ascii(substr(l_data,18,1) );
    end loop;
    p_bfile_offset := p_bfile_offset +
    mod( p_hdr.hdr_len - l_hdr_size,
    l_field_desc_size );
    end;
    function build_insert
    ( p_tname in varchar2,
    p_cnames in varchar2,
    p_flds in field_descriptor_array ) return varchar2
    is
    l_insert_statement long;
    begin
    l_insert_statement := 'insert into ' || p_tname || '(';
    if ( p_cnames is NOT NULL )
    then
    l_insert_statement := l_insert_statement ||
    p_cnames || ') values (';
    else
    for i in 1 .. p_flds.count
    loop
    if ( i <> 1 )
    then
    l_insert_statement := l_insert_statement||',';
    end if;
    l_insert_statement := l_insert_statement ||
    '"'|| p_flds(i).name || '"';
    end loop;
    l_insert_statement := l_insert_statement ||
    ') values (';
    end if;
    for i in 1 .. p_flds.count
    loop
    if ( i <> 1 )
    then
    l_insert_statement := l_insert_statement || ',';
    end if;
    if ( p_flds(i).type = 'D' )
    then
    l_insert_statement := l_insert_statement ||
    'to_date(:bv' || i || ',''yyyymmdd'' )';
    else
    l_insert_statement := l_insert_statement ||
    ':bv' || i;
    end if;
    end loop;
    l_insert_statement := l_insert_statement || ')';
    return l_insert_statement;
    end;
    function get_row
    ( p_bfile in bfile,
    p_bfile_offset in out number,
    p_hdr in dbf_header,
    p_flds in field_descriptor_array ) return rowArray
    is
    l_data varchar2(4000);
    l_row rowArray;
    l_n number default 2;
    begin
    l_data := utl_raw.cast_to_varchar2(
    dbms_lob.substr( p_bfile,
    p_hdr.rec_len,
    p_bfile_offset ) );
    p_bfile_offset := p_bfile_offset + p_hdr.rec_len;
    l_row(0) := substr( l_data, 1, 1 );
    for i in 1 .. p_hdr.no_fields loop
    l_row(i) := rtrim(ltrim(substr( l_data,
    l_n,
    p_flds(i).length ) ));
    if ( p_flds(i).type = 'F' and l_row(i) = '.' )
    then
    l_row(i) := NULL;
    end if;
    l_n := l_n + p_flds(i).length;
    end loop;
    return l_row;
    end get_row;
    procedure show( p_hdr in dbf_header,
    p_flds in field_descriptor_array,
    p_tname in varchar2,
    p_cnames in varchar2,
    p_bfile in bfile )
    is
    l_sep varchar2(1) default ',';
    procedure p(p_str in varchar2)
    is
    l_str long default p_str;
    begin
    while( l_str is not null )
    loop
    dbms_output.put_line( substr(l_str,1,250) );
    l_str := substr( l_str, 251 );
    end loop;
    end;
    begin
    p( 'Sizeof DBASE File: ' || dbms_lob.getlength(p_bfile) );
    p( 'DBASE Header Information: ' );
    p( chr(9)||'Version = ' || p_hdr.version );
    p( chr(9)||'Year = ' || p_hdr.year );
    p( chr(9)||'Month = ' || p_hdr.month );
    p( chr(9)||'Day = ' || p_hdr.day );
    p( chr(9)||'#Recs = ' || p_hdr.no_records);
    p( chr(9)||'Hdr Len = ' || p_hdr.hdr_len );
    p( chr(9)||'Rec Len = ' || p_hdr.rec_len );
    p( chr(9)||'#Fields = ' || p_hdr.no_fields );
    p( chr(10)||'Data Fields:' );
    for i in 1 .. p_hdr.no_fields
    loop
    p( 'Field(' || i || ') '
    || 'Name = "' || p_flds(i).name || '", '
    || 'Type = ' || p_flds(i).Type || ', '
    || 'Len = ' || p_flds(i).length || ', '
    || 'Scale= ' || p_flds(i).decimals );
    end loop;
    p( chr(10) || 'Insert We would use:' );
    p( build_insert( p_tname, p_cnames, p_flds ) );
    p( chr(10) || 'Table that could be created to hold data:');
    p( 'create table ' || p_tname );
    p( '(' );
    for i in 1 .. p_hdr.no_fields
    loop
    if ( i = p_hdr.no_fields ) then l_sep := ')'; end if;
    dbms_output.put
    ( chr(9) || '"' || p_flds(i).name || '" ');
    if ( p_flds(i).type = 'D' ) then
    p( 'date' || l_sep );
    elsif ( p_flds(i).type = 'F' ) then
    p( 'float' || l_sep );
    elsif ( p_flds(i).type = 'N' ) then
    if ( p_flds(i).decimals > 0 )
    then
    p( 'number('||p_flds(i).length||','||
    p_flds(i).decimals || ')' ||
    l_sep );
    else
    p( 'number('||p_flds(i).length||')'||l_sep );
    end if;
    else
    p( 'varchar2(' || p_flds(i).length || ')'||l_sep);
    end if;
    end loop;
    p( '/' );
    end;
    procedure load_Table( p_dir in varchar2,
    p_file in varchar2,
    p_tname in varchar2,
    p_cnames in varchar2 default NULL,
    p_show in boolean default FALSE )
    is
    l_bfile bfile;
    l_offset number default 1;
    l_hdr dbf_header;
    l_flds field_descriptor_array;
    l_row rowArray;
    begin
    l_bfile := bfilename( p_dir, p_file );
    dbms_lob.fileopen( l_bfile );
    get_header( l_bfile, l_offset, l_hdr, l_flds );
    if ( p_show )
    then
    show( l_hdr, l_flds, p_tname, p_cnames, l_bfile );
    else
    dbms_sql.parse( g_cursor,
    build_insert(p_tname,p_cnames,l_flds),
    dbms_sql.native );
    for i in 1 .. l_hdr.no_records loop
    l_row := get_row( l_bfile,
    l_offset,
    l_hdr,
    l_flds );
    if ( l_row(0) <> '*' ) -- deleted record
    then
    for i in 1..l_hdr.no_fields loop
    dbms_sql.bind_variable( g_cursor,
    ':bv'||i,
    l_row(i),
    4000 );
    end loop;
    if ( dbms_sql.execute( g_cursor ) <> 1 )
    then
    raise_application_error( -20001,
    'Insert failed ' || sqlerrm );
    end if;
    end if;
    end loop;
    end if;
    dbms_lob.fileclose( l_bfile );
    exception
    when others then
    if ( dbms_lob.isopen( l_bfile ) > 0 ) then
    dbms_lob.fileclose( l_bfile );
    end if;
    RAISE;
    end;
    end;
    i think i am doing mistake in creating and using directory ..direct me plz..

  • Error in updating a blob column

    hi good morning every one,
    first of all i created directory images as 'C:\images'
    then i created table PRICUSTOMERPROOF
    Name                     Null Type        
    CUSTOMERID                    VARCHAR2(50)
    IMAGEID                            NUMBER      
    IDTYP                                 NUMBER      
    IDVALUE                            VARCHAR2(50)
    IDEXPDATE                        TIMESTAMP(6)
    IDIMAGE                            BLOB        
    ACTIVEC                            NUMBER(1)   
    USERR                              VARCHAR2(10)
    DATEE                              TIMESTAMP(6)
    DEFAULTC                        NUMBER(1)   
    CUSTOMERIDENTIFICATIONID      NUMBER 
    then i inserted all the values in the table except IDIMAGE column
    then i tried to update the column with
    DECLARE
      l_bfile  BFILE;
      l_blob   BLOB;
    BEGIN
      SELECT IDIMAGE
      INTO   l_blob
      FROM   PRICUSTOMERPROOF
      WHERE CUSTOMERID = 'Pri29098'
      FOR UPDATE;
      l_bfile := BFILENAME(upper('images'), 'Tulips.jpg');
      DBMS_LOB.fileopen(l_bfile, Dbms_Lob.File_Readonly);
      DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
      DBMS_LOB.fileclose(l_bfile);
    END;
    when i execute the codes i am getting
    Error report:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 805
    ORA-06512: at line 12
    22285. 00000 -  "non-existent directory or file for %s operation"
    *Cause:    Attempted to access a directory that does not exist, or attempted
               to access a file in a directory that does not exist.
    *Action:   Ensure that a system object corresponding to the specified
               directory exists in the database dictionary, or
               make sure the name is correct.
    im sure the image directory exists. can any one help me in getting the errors cleared
    thanking you
    prakash

    OWNER                          DIRECTORY_NAME                 DIRECTORY_PATH                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    SYS                            IMAGES                         C:\images                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
    SYS                            ORACLECLRDIR                   D:\PRAKASHFILES\oracleXEpath\app\oracle\product\11.2.0\server\bin\clr                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    SYS                            DATA_PUMP_DIR                  D:\PRAKASHFILES\oracleXEpath\app\oracle\admin\xe\dpdump\                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    SYS                            XMLDIR                         D:\PRAKASHFILES\oracleXEpath\app\oracle\product\11.2.0\server\rdbms\xml                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    SYS                            ORACLE_OCM_CONFIG_DIR          C:/ADE/jaikrish_xe/oracle\ccr\state                   
    these are the directories and i also granted write and read privilege to the user
    then i executed the codes, then
    Error report:
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
    ORA-06512: at "SYS.DBMS_LOB", line 928
    ORA-06512: at line 13
    06502. 00000 -  "PL/SQL: numeric or value error%s"

  • Error while trying to use BFILENAME during schema registration

    Hi,
    I'm having difficulty in understanding the BFILENAME function while trying to register a schema. The schema is physically present in the following location
    USERNAME: WEBUSER
    LOCATION: XML Schemas ---> MyHeaderSchema.xsd
    And I'm trying to register it as follows:
    declare
    V_XML_SCHEMA XMLTYPE := XMLType(BFILENAME('WEBUSER','MyHeaderSchema.xsd'),nls_charset_id('AL32UTF8'));
    begin
    DBMS_XMLSCHEMA.registerSchema
    SCHEMAURL => 'http://my.schemas.com/header.xsd',
    SCHEMADOC => V_XML_SCHEMA,
    LOCAL => TRUE,
    GENBEAN => FALSE,
    GENTYPES => TRUE,
    GENTABLES => FALSE,
    ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
    end;
    I get the error:
    Error report:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.XMLTYPE", line 296
    ORA-06512: at line 2
    22285. 00000 - "non-existent directory or file for %s operation"
    *Cause:    Attempted to access a directory that does not exist, or attempted
    to access a file in a directory that does not exist.
    *Action:   Ensure that a system object corresponding to the specified
    directory exists in the database dictionary, or
    make sure the name is correct.
    Can you please help?

    I was curious if there was already some functionality in SQL Developer I might have missed. So I checked. Apparently SQL Developer still doesn't have any functionality to support XML Schema's in / for XMLDB (I keep them asking, but anyway).
    So an XML Schema is just treated as plain text. Still.
    However, the following worked for me. Is there a difference if I use XDBURIType Vs BFILENAME and do a getBLOB() Vs XMLType?XDBUriType is part of the URIType factory functionality and in this case, XDBUritype enables you to get the content stored out of the XDB Repository
    BFileName give you the possibility to get your content from the server via a BFile locator construct
    getBLOB is an operator on xdburitype and converts the uritype datatype into binary LOB datatype
    XMLType is the datatype that should be used for XML content
    If you use GENTYPES => TRUE then during registration via using DBMS_XMLSCHEMA objects and types will be created to "represent" the "format" of the XML defined by the XML Schema.

  • Problem with bfilename(directory_name,file_name) function

    Hi all,
    I have a problem with this function. I have built and pl/sql program in order to send an email wich includes "pdf" file.
    I have found that bfilename function works fine when you want to send a pdf file.
    However, when I execute this query
    SELECT bfilename('/usr/tmp', 'pdf_report.pdf') dato
    FROM dual;
    The result shows in the screen : /usr/tmp//pdf_report.pdf (NoExist)
    I don't know why the path includes double "//".
    Then, I wanted to open the file in this way
    bfile_len := dbms_lob.getlength(bfile_handle);
    pos := 1;
    dbms_lob.open(bfile_handle,dbms_lob.lob_readonly);
    an error occurs :
    ORA-22285: non-existent directory or file for GETLENGTH operation.
    I infere that the problem is "//" but I don't know why it happened.
    Can I use another function in order to send a pdf file inside an email ? Or can I change a blob type column in order to replace "/" insted of "//" ?.
    I appreciate your help.
    Best Regards,
    Mariano.-

    Hi Damorgan,
    I did what you told me but the error still appears.
    I created my directory in the database. But when the program executed the line with the "fileopen sentence" the error appeared again.
    I saw that the directory contained '//' instead of '/'. Can I use another function in order to send a pdf file inside an email ?
    Thanks for your cooperation and patience.
    Best Regards.
    Mariano.-

  • Error while using dbms_lob.fileopen

    Hi,
    I am getting the below error when executing the code given below,
    CODE:-
    DECLARE
    l_bfile BFILE;
    l_data BLOB;
    BEGIN
    DBMS_LOB.createtemporary (lob_loc => l_data,
    CACHE => TRUE,
    dur => DBMS_LOB.CALL);
    l_bfile := BFILENAME('/home/lt/write','MIA00137.inp');
    DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
    END;
    ERROR:-
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 523
    ORA-06512: at line 12
    I am using the directory path instead of using the directory name, which is my requirement. How can I overcome the above error.
    Thanks
    RKR

    You should use a directory object not a file system directory.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5007.htm#sthref6399
    Bye Alessandro

  • Wrong path?

    Hi, another question,
    i want to import an xml-file from my local disk like
    create or replace directory xmldir as '/home/oracle/Documents/';
    insert into dblptest
    values (xdb_utilities.getXMLfromfile('note.xml','xmldir');
    but the error:
    ERROR at line 1:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 523
    ORA-06512: at "JIESUN.XDB_UTILITIES", line 38
    ORA-06512: at "JIESUN.XDB_UTILITIES", line 113
    ORA-06512: at "JIESUN.XDB_UTILITIES", line 174
    ORA-06512: at "JIESUN.XDB_UTILITIES", line 211
    ORA-06512: at line 1
    I really have note.xml under /home/oracle/Documents/ and i use SuSE9.2
    Any suggestion?
    thx
    aalex

    In 10.1.x you do not need the helper function
    Simply try
    xmltype(bfilename('SQLDIRNAME','xmlfilename'),nls_charset_id('AL32UTF8))

  • Problem using image.setSource ?

    Hi,
    Can anyone see what I'm doing wrong here ?
    I'm sure it's something obvious but I can't see it.
    1) I have made a directory /images/ with full rw access
    ================================
    ls -la /images/total 52
    drwxrwxrwx 2 root root 1024 Jun 19 14:58 .
    drwxr-xr-x 24 root root 1024 Jun 19 16:37 ..
    -rwxrwxrwx 1 ora816 dba 50000 Jun 19 14:58 test.gif
    2) Create a directory from sql as system
    ===============================
    SQL> create directory IMGDIR as '/images';
    Directory created.
    3) Try to load the "test.gif" file but get a non-existent file or directory failure
    ==================================
    DECLARE
    -- applicaition variables
    Image ORDSYS.ORDImage;
    ctx RAW(4000) :=NULL;
    BEGIN
    DELETE FROM emp WHERE ename = 'John Doe';
    INSERT INTO emp VALUES
    ('John Doe'
    , 24000
    , 'Technical Writer'
    , 123
    , ORDSYS.ORDImage(ORDSYS.ORDSource(empty_blob(), NULL,NULL,NULL,SYSDATE,1),
    NULL,NULL,NULL,NULL,NULL,NULL,NULL)
    , ORDSYS.ORDImage(ORDSYS.ORDSource(empty_blob(), NULL,NULL,NULL,SYSDATE,1),
    NULL,NULL,NULL,NULL,NULL,NULL,NULL));
    -- select the newly inserted row for update
    SELECT photo INTO Image FROM emp
    WHERE ename = 'John Doe' for UPDATE;
    -- This example imports the image file test.gif from the IMGDIR
    -- directory on a local file system.
    Image.setSource('FILE','IMGDIR','test.gif');
    Image.import(ctx);
    --END;
    -- set property attributes for the image data
    Image.setProperties;
    UPDATE emp SET photo = Image WHERE ename = 'John Doe';
    COMMIT;
    -- continue processing
    END;
    SQL> /
    DECLARE
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "ORDSYS.ORDSOURCE", line 183
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "ORDSYS.ORDIMG_PKG", line 484
    ORA-06512: at "ORDSYS.ORDIMAGE", line 175
    ORA-06512: at line 26
    null

    This error occured because the user who ran the PL/SQL script did not have the privilege to read the IMGDIR directory.
    You can give the privilege to the user as SYSTEM:
    SQL> grant read on directory IMGDIR to user;
    Then the user should be able to find the IMGDIR directory and run the PL/SQL script without the error.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by niallmcp ():
    Can anyone see what I'm doing wrong here ?
    I'm sure it's something obvious but I can't see it.
    2) Create a directory from sql as system
    ===============================
    SQL> create directory IMGDIR as '/images';
    Directory created.
    SQL> /
    DECLARE
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "ORDSYS.ORDSOURCE", line 183
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "ORDSYS.ORDIMG_PKG", line 484
    ORA-06512: at "ORDSYS.ORDIMAGE", line 175
    ORA-06512: at line 26
    <HR></BLOCKQUOTE>
    null

  • Problem with loading file to BLOB column

    I am attempting to load up a .gif gile into a BLOB column in my database.
    I created the directory as below:
    ===
    SQL> create or replace directory example_lob_dir as 'C:\temp';
    Directory created.
    ===
    Next I created the following procedure to load the file into the BLOB column:
    ====
    create or replace procedure load_blob as
    dest_loc blob; -- destination location
    src_loc bfile := bfilename('example_lob_dir', 'example.gif'); -- source location
    begin
    -- Insert intial BLOB value
    insert into test_blob(id, file_name, image)
    values (1, 'test.gif', empty_blob())
    returning image into dest_loc;
    -- Open the source BFILE
    dbms_lob.open(src_loc, dbms_lob.lob_readonly);
    -- Open the LOB (optional)
    dbms_lob.open(dest_loc, dbms_lob.lob_readwrite);
    -- Load the file
    dbms_lob.loadfromfile(
    dest_lob => dest_loc,
    src_lob => src_loc,
    amount => dbms_lob.getlength(src_loc));
    -- Close LOBs
    dbms_lob.close(dest_loc);
    dbms_lob.close(src_loc);
    commit;
    end load_blob;
    ===
    The file is definitely in the C:\temp folder and is named correctly. I am working in WinXP with Oracle10gXE and both server and client are on the same machine.
    The procedure compiles without any errors but when I attempt to run it I get an error message as below:
    ==
    SQL> exec load_blob
    BEGIN load_blob; END;
    ERROR at line 1:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 716
    ORA-06512: at "FTM.LOAD_BLOB", line 14
    ORA-06512: at line 1
    ==
    Any help would be much appreciated.

    When you create objects on the database they are stored in the data dictionary by default in UPPER case.
    So in this line:
    src_loc bfile := bfilename('example_lob_dir', 'example.gif'); -- source location
    you need to reference the name of the directory object in upper case. e.g.
    src_loc bfile := bfilename('EXAMPLE_LOB_DIR', 'example.gif'); -- source location
    ;)

  • DBMS_LOB.FILEOPEN(dir, fname) gives non-existent dir or file error

    Hello!
    I've been trying to load an image file into the oracle database using the DBMS_LOB loadfromfile procedure. In order to do this, I first have to open the appropriate file which I do using
    temp_bfile := bfilename('temp_dir', in_filename);
    where in_filename is a string having the appropriate filename. and 'temp_dir' is a directory object created as follows:
    CREATE DIRECTORY temp_dir AS 'F:\';
    Next when I do a
    DBMS_LOB.FILEOPEN(temp_bfile, LOB_READONLY);
    I get an exception ORA-22285:non-existent directory or file.
    What am I doing wrong? Is the way I've created the directory object correct. I work on an NT machine.
    Mona

    Not sure if the UTL_FILE package is the same but if you don't set the "utl_file_dir" variable in the INIT.ORA file prior to calling the FOPEN procedure you will get a similiar error. There may be an equivalent parameter for the DBMS_LOB package.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Mona Marathe ([email protected]):
    Hello!
    I've been trying to load an image file into the oracle database using the DBMS_LOB loadfromfile procedure. In order to do this, I first have to open the appropriate file which I do using
    temp_bfile := bfilename('temp_dir', in_filename);
    where in_filename is a string having the appropriate filename. and 'temp_dir' is a directory object created as follows:
    CREATE DIRECTORY temp_dir AS 'F:\';
    Next when I do a
    DBMS_LOB.FILEOPEN(temp_bfile, LOB_READONLY);
    I get an exception ORA-22285:non-existent directory or file.
    What am I doing wrong? Is the way I've created the directory object correct. I work on an NT machine.
    Mona<HR></BLOCKQUOTE>
    null

  • Error when using CLOB

    Problem While using CLOB/BLOB datatype:
    We have created a directory in E drive and created a directory alias in oracle.
    to read the data from CLOB data type we have to write a PL/SQL code.
    But i am getting an errorin the block .ie non existent directory or file....
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 475
    ORA-06512: at line 8
    but the directory and file is there with all permissions.
    null

    Hi,
    Your buffer size should be the clob size.
    char[] buffer = new char[c_lob.getBufferSize()];
    Also, set the value for i as -1.
    You could see the sample on OTN for help:
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/Readme.html
    Thanks,
    Rashmi

Maybe you are looking for

  • Restoring my new Iphone 5 from my backup. It is asking for an encryption password but i never set one up

    I've backuped my phone and then had it replaced as it was broken. Went to retore my new phone Iphone 5 and it is asking for a encryption password. I didn't set one two days ago. I have tried my itunes password, the computer password my iphone lock pa

  • Gaming On Minis

    Hey, I'm probably going to buy a mac mini very soon (Either the PPC 1.25GHZ 512 Ram, PPC 1.42GHZ 512 Ram or Intel Core Solo 1.5GHZ). I'm not a heavy gamer but I enjoy World of Warcraft, Warcraft III and some shooters like Half Life. I don't care abou

  • Ship to party in VA01  in which table ship to party stored

    hi all please tell ship to party in VA01 in which table ship to party stored while creating sales document by va01

  • Why am I not eligible for the discounted plan?

    Hello Adobe world, I have a full and real copy of the Educational version of Adobe Creative Suite CS5 on my laptop. When I went to upgrade to the Creative Cloud, I put in my adobe number and it said I was not eligible. I think it is because it is an

  • Help Please!  Safari keeps closing!

    My Safari window closes every time I try to type in the address bar. I can open web pages from my history, but I cannot go to a new webpage without the window closing. Thanks so much for your help! Below is the error report: Date/Time: 2011-02-13 13: