<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Decode360's Blog

    業(yè)精于勤而荒于嬉 QQ:150355677 MSN:decode360@hotmail.com

      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 ::  :: 管理 ::
      302 隨筆 :: 26 文章 :: 82 評(píng)論 :: 0 Trackbacks
    ??? 學(xué)習(xí)一下如何在Oracle中存儲(chǔ)圖片、影像等大文件。廢話不多說了,直接上代碼。
    ??? 注:后面那段是用于直接輸出html代碼在網(wǎng)頁(yè)展現(xiàn)的腳本。
    ?
    SQL> create table demo
    ? 2? ( id??????? int primary key,
    ? 3??? theBlob???blob
    ? 4? )
    ? 5? /
    ?
    Table created.
    ?
    ?
    SQL> create or replace directory my_files as 'D:\TEST\Image';
    ?
    Directory created.
    ?
    ?
    SQL> declare
    ? 2????? l_blob??? blob;
    ? 3????? l_bfile?? bfile;
    ? 4? begin
    ? 5????? insert into demo values ( 1, empty_blob() )
    ? 6????? returning theBlob into l_blob;
    ? 7
    ? 8????? l_bfile := bfilename( 'MY_FILES', 'af73.jpg' );
    ? 9????? dbms_lob.fileopen( l_bfile );
    ?10
    ?11????? dbms_lob.loadfromfile( l_blob, l_bfile,
    ?12?????????????????????????????dbms_lob.getlength( l_bfile ) );
    ?13
    ?14????? dbms_lob.fileclose( l_bfile );
    ?15? end;
    ?16? /
    ?
    PL/SQL procedure successfully completed.
    ?
    --done
    ?
    ?
    ?
    ?

    --Now here is the package that can retrieve the pdf (or anything for that matter.? Just
    --keep adding procedures that are named after the file type like .doc, .pdf, .xls and so
    --on.? Some browsers really want the extension in the URL to be "correct")

    SQL> create or replace package image_get
    ? 2? as
    ? 3????? procedure gif( p_id in demo.id%type );
    ? 4? end;
    ? 5? /
    ?
    Package created.
    ?
    SQL>
    SQL> create or replace package body image_get
    ? 2? as
    ? 3
    ? 4? procedure gif( p_id in demo.id%type )
    ? 5? is
    ? 6????? l_lob???blob;
    ? 7????? l_amt???number default 30;
    ? 8????? l_off?? number default 1;
    ? 9????? l_raw?? raw(4096);
    ?10? begin
    ?11????? select theBlob into l_lob
    ?12??????? from demo
    ?13???????where id = p_id;
    ?14???????-- make sure to change this for your type!
    ?15????? owa_util.mime_header( 'image/gif' );
    ?16
    ?17????????? begin
    ?18???????????? loop
    ?19??????????????? dbms_lob.read( l_lob, l_amt, l_off, l_raw );
    ?20
    ?21??????????????? -- it is vital to use htp.PRN to avoid
    ?22??????????????? -- spurious line feeds getting added to your
    ?23??????????????? -- document
    ?24??????????????? htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
    ?25??????????????? l_off := l_off+l_amt;
    ?26??????????????? l_amt := 4096;
    ?27???????????? end loop;
    ?28????????? exception
    ?29???????????? when no_data_found then
    ?30??????????????? NULL;
    ?31????????? end;
    ?32? end;
    ?33
    ?34? end;
    ?35? /
    ?
    Package body created.
    ?
    ?
    ?
    ?
    ??? 注:以上腳本涉及到的系統(tǒng)包有:DBMS_LOB | OWA_UTIL | UTL_RAW | HTP
    ?
    ??????? UTL_RAW might not be installed on your database.? It is part of replication.?
    ??????? If you?do not have it installed, simply:
    ??????? o cd $ORACLE_HOME/rdbms/admin
    ??????? o find the two files with "raw" in their name (eg: ls *raw*)
    ??????? o using svrmgrl connect as INTERNAL OR SYS -- only these users, no one else can?successfully install UTL_RAW
    ??????? o run the .sql and then the .plb file
    ?
    ??? 系統(tǒng)包使用方法可查看《PLSQL Packages and Types Reference》
    ?
    ?
    ?




    -The End-

    posted on 2009-03-16 21:45 decode360-3 閱讀(742) 評(píng)論(0)  編輯  收藏 所屬分類: Oracle
    主站蜘蛛池模板: 国产成人免费高清在线观看| 亚洲精品无码成人| 亚洲国产精品lv| 亚洲理论电影在线观看| 中国亚洲女人69内射少妇| 久久久久亚洲AV无码去区首| 国产成人精品日本亚洲18图| 亚洲a级成人片在线观看| 亚洲成av人片不卡无码| 亚洲av乱码一区二区三区香蕉| 亚洲精品在线免费观看视频| 亚洲国产精品综合福利专区| 亚洲va在线va天堂成人| 日韩亚洲产在线观看| 亚洲AV午夜成人影院老师机影院| 国产亚洲一区二区在线观看 | 国产免费一区二区三区免费视频| 久久久久亚洲AV无码网站| 色婷婷亚洲十月十月色天| 亚洲白色白色永久观看| 亚洲男人天堂2018av| 亚洲A∨精品一区二区三区下载| 视频一区二区三区免费观看| 51午夜精品免费视频| 国产精品亚洲а∨天堂2021| 四虎影视久久久免费| 免费人成在线观看视频高潮| 亚洲一区免费观看| 中文在线观看永久免费| 一区二区免费视频| 日韩吃奶摸下AA片免费观看| 国产黄色片在线免费观看| 亚洲伊人久久成综合人影院| 久久精品7亚洲午夜a| 亚洲天堂电影在线观看| 亚洲AV噜噜一区二区三区| 一级毛片在播放免费| 免费不卡在线观看AV| 好男人视频在线观看免费看片| 亚洲第一永久AV网站久久精品男人的天堂AV | 中文字幕一区二区免费|