2
votes

I'm trying to load a LOB file to a table and ORA-22288. I fail on DBMS_LOB.FILEOPEN(src_clob);

What can be the cause? The directory exists and file is located in the directory.

I do the following:

  1. Connect as SYSTEM
  2. Execute the following commands:

    SQL>create or replace directory MY_DIR as 'C:\oracle\admin\MYDB\create\lob';
    

    SQL>Grant all on directory MY_DIR to MYDBUSER;

  3. Connect as MYDBUSER and call a procedure SQL>LOAD_LOB_FROM_FILE(10,'insert_details_view.xsl','XMLXSL_DATA_T','FILE_ID','LOB_FILE');

The procedure is:

CREATE OR REPLACE PROCEDURE LOAD_LOB_FROM_FILE(p_FileId  NUMBER, p_FileName  
VARCHAR2,p_TableName VARCHAR2, p_IDColumnName VARCHAR2, p_FileColoumnName VARCHAR2)
IS
    dest_clob   CLOB;
    src_clob    BFILE  := BFILENAME('MY_DIR', p_FileName);
    dest_length number;
    str_query   CLOB;

BEGIN

  -- This procedure handles updates of all files in the databse - LOB, Json and XSL.
  -- The procedure recieves dynamic parameters in order to work for all contexts and file types
  str_query := 'SELECT ' || p_FileColoumnName || ' FROM ' || p_TableName || ' WHERE ' || p_IDColumnName || ' = ' || p_FileId || ' FOR UPDATE ';

  EXECUTE IMMEDIATE str_query INTO dest_clob;

  DBMS_LOB.FILEOPEN(src_clob);

  -- It is necessary to clear the old clob before updating with the new one to prevent the file destruction.
  dest_length := DBMS_LOB.GETLENGTH(dest_clob);
  IF dest_length <> 0 THEN
      DBMS_LOB.ERASE(dest_clob,dest_length,1);
  END IF;

  DBMS_LOB.LOADFROMFILE(dest_clob,src_clob,DBMS_LOB.GETLENGTH(src_clob));

  str_query := 'UPDATE ' || p_TableName || ' SET ' || p_FileColoumnName || ' = ''' || dest_clob ||''' WHERE ' || p_IDColumnName || ' = ' || p_FileId;

  EXECUTE IMMEDIATE str_query;
  DBMS_LOB.FILECLOSE(src_clob);
  COMMIT;
END;
/

Full error stack:

ERROR at line 1: ORA-22288: file or LOB operation FILEOPEN failed The filename, directory name, or volume label syntax is incorrect.

ORA-06512: at "SYS.DBMS_LOB", line 805

ORA-06512: at "VSU22.LOAD_LOB_FROM_FILE", line 16

ORA-06512: at line 3

1
Do you know the line of the error?Florin Ghita
Also the whole error stack? Ex: * ERROR at line 1: ORA-22288: file or LOB operation FILEOPEN failed No such file or directory ORA-06512: at "SYS.DBMS_LOB", line 805 ORA-06512: at line 6Felipe Moreno
@FelipeMoreno Added full error stack.David Faizulaev
@FlorinGhita, Added full error stack.David Faizulaev
Thanks, David. That didn't clarify much tough. There are some known bugs at Windows with DBMS_LOB manipulation. Do you have access to My Oracle Support? Check for "windows ORA-22288" for example. Ex: Bug 4632494 - Win: ORA-22288 when file name includes 0x5c (Doc ID 4632494.8), ORA-22288: File Or LOB Operation FILEOPEN Failed On Windows2008 R2 OS SAN Attached Drive (Doc ID 1504521.1)Felipe Moreno

1 Answers

0
votes

The parameter passed to the installer used was incorrect (lack of attention).