Use dbms_lob.fileopen to open bfile
SQL>
SQL> create table bfile_table(
2 name varchar2(255),
3 the_file bfile );
Table created.
SQL> insert into bfile_table values ( 'doc 1', bfilename( 'WROX_DIR', 'my_doc.pdf' ) );
1 row created.
SQL>
SQL> declare
2 l_bfile bfile;
3 l_dir_alias varchar2(2000);
4 l_filename varchar2(2000);
5 begin
6 select the_file
7 into l_bfile
8 from bfile_table
9 where name = 'doc 1';
10 dbms_lob.fileopen( l_bfile, dbms_lob.file_readonly );
11 if dbms_lob.fileexists( l_bfile ) = 1 then
12 dbms_lob.filegetname( l_bfile, l_dir_alias, l_filename );
13 dbms_output.put_line( 'Directory alias: ' || l_dir_alias );
14 dbms_output.put_line( 'Filename: ' || l_filename );
15 end if;
16 if dbms_lob.fileisopen( l_bfile ) = 1 then
17 dbms_lob.fileclose( l_bfile );
18 end if;
19 end;
20 /
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 10
SQL>
SQL> drop table bfile_table;
Table dropped.
SQL>
SQL>
SQL> --
Related examples in the same category