Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Data Types
 

Open the target CLOB and the source BFILE

SQL> SQL> CREATE TABLE facebook (   2     name VARCHAR2(80),   3     photo BLOB,   4     directions CLOB,   5     description NCLOB,   6     web_page BFILE); Table created. SQL> SQL> CREATE DIRECTORY bfile_data AS 'c:\xxx'; Directory created. SQL> SQL> DECLARE   2     myBFile BFILE := BFILENAME('BFILE_DATA','TanneryFalls.directions');   3     directions CLOB;   4     destination_offset INTEGER := 1;   5     source_offset INTEGER := 1;   6     language_context INTEGER := DBMS_LOB.default_lang_ctx;   7     warning_message INTEGER;   8  BEGIN   9     DELETE FROM facebook WHERE name='Falls';  10  11     INSERT INTO facebook (name,directions) VALUES ('Falls',EMPTY_CLOB(  ));  12  13     SELECT directions INTO directions FROM facebook WHERE name='Falls';  14  15  16     DBMS_LOB.OPEN(directions, DBMS_LOB.LOB_READWRITE);  17     DBMS_LOB.OPEN(myBFile);  18  19     DBMS_LOB.LOADCLOBFROMFILE(directions, myBFile,  20                               DBMS_LOB.LOBMAXSIZE,  21                               destination_offset, source_offset,  22                               NLS_CHARSET_ID('US7ASCII'),  23                               language_context, warning_message);  24  25     IF warning_message = DBMS_LOB.WARN_INCONVERTIBLE_CHAR THEN  26          dbms_output.put_line(  27             'Warning! Some characters couldn''t be converted.');  28     END IF;  29  30     DBMS_LOB.CLOSE(directions);  31     DBMS_LOB.CLOSE(myBFile);  32  END;  33  / DECLARE * ERROR at line 1: ORA-22288: file or LOB operation FILEOPEN failed The system cannot find the path specified. ORA-06512: at "SYS.DBMS_LOB", line 716 ORA-06512: at line 17 SQL> SQL> drop table facebook; Table dropped. SQL> drop directory bfile_data; Directory dropped.