全部博文(136)
分类: Oracle
2008-06-06 15:18:27
D:\temp>dir wat*
驱动器 D 中的卷是 D 卷的序列号是 15C2-D261 D:\temp 的目录
2008-06-06 11:08 56,073 waterfall.gif 1 个文件 56,073 字节 0 个目录 7,558,959,104 可用字节 |
SQL> create directory bfile_data as 'D:\temp';
目录已创建。 |
SQL> DECLARE
2 waterfall_picture BFILE; 3 BEGIN 4 --Invoke BFILENAME to create a BFILE locator 5 waterfall_picture := BFILENAME('BFILE_DATA','waterfall.gif'); 6 7 --Save our new locator in the waterfalls table 8 INSERT INTO waterfalls (falls_name, falls_web_page) 9 VALUES ('my waterfall',waterfall_picture); 10 END; 11 / PL/SQL 过程已成功完成。 |
SQL> DECLARE
2 waterfall BFILE; 3 piece RAW(60); 4 amount BINARY_INTEGER := 60; 5 offset INTEGER := 1; 6 BEGIN 7 --Retrieve the LOB locator 8 SELECT falls_web_page 9 INTO waterfall 10 FROM waterfalls 11 WHERE falls_name='my waterfall'; 12 13 --Open the locator, read 60 bytes, and close the locator 14 DBMS_LOB.OPEN(waterfall); 15 DBMS_LOB.READ(waterfall, amount, 1, piece); 16 DBMS_LOB.CLOSE(waterfall); 17 18 --Display results in hex 19 DBMS_OUTPUT.PUT_LINE(RAWTOHEX(piece)); 20 21 --Cast RAW results to a character string we can read 22 --DBMS_OUTPUT.PUT_LINE(UTL_RAW.CAST_TO_VARCHAR2(piece)); 23 END; 24 / 474946383961CF01320277003121FE1A536F6674776172653A204D6963726F736F6674204F666669 63650021F90401000000002C00000000CE013102 PL/SQL 过程已成功完成。 |
SQL> show parameter session_max
NAME TYPE
VALUE ------------------------------------ ----------- ----- session_max_open_files integer 10 |
SQL> DECLARE
2 My_Falls_Directions BFILE := BFILENAME('BFILE_DATA','waterfall.gif'); 3 photo BLOB; 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 row for Tannery Falls, so this example 10 --can run multiple times. 11 DELETE FROM waterfalls WHERE falls_name='my waterfall'; 12 13 --Insert a new row using EMPTY_BLOB( ) to create a LOB locator 14 INSERT INTO waterfalls 15 (falls_name,FALLS_PHOTO) 16 VALUES ('my waterfall',EMPTY_BLOB( )); 17 18 --Retrieve the LOB locator created by the previous INSERT statement 19 SELECT FALLS_PHOTO 20 INTO photo 21 FROM waterfalls 22 WHERE falls_name='my waterfall'; 23 24 --Open the target BLOB and the source BFILE 25 DBMS_LOB.OPEN(photo, DBMS_LOB.LOB_READWRITE); 26 DBMS_LOB.OPEN(My_Falls_Directions); 27 28 --Load the contents of the BFILE into the BLOB column 29 DBMS_LOB.LOADBLOBFROMFILE(photo, My_Falls_Directions, 30 DBMS_LOB.LOBMAXSIZE, 31 destination_offset, source_offset); 32 33 --Close both LOBs 34 DBMS_LOB.CLOSE(photo); 35 DBMS_LOB.CLOSE(My_Falls_Directions); 36 END; 37 / PL/SQL 过程已成功完成。 |