<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 :: 首頁 :: 新隨筆 :: 聯(lián)系 ::  :: 管理 ::
      302 隨筆 :: 26 文章 :: 82 評論 :: 0 Trackbacks
    ??? 學(xué)習(xí)一下如何在Oracle中存儲圖片、影像等大文件。廢話不多說了,直接上代碼。
    ??? 注:后面那段是用于直接輸出html代碼在網(wǎng)頁展現(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 閱讀(743) 評論(0)  編輯  收藏 所屬分類: Oracle
    主站蜘蛛池模板: 十八禁的黄污污免费网站| 亚洲AV色欲色欲WWW| 日产乱码一卡二卡三免费| 无码人妻久久一区二区三区免费| 亚洲乱码一区av春药高潮| 国产亚洲一区二区三区在线不卡 | 免费一级肉体全黄毛片| 日韩人妻无码精品久久免费一 | 亚洲黄黄黄网站在线观看| 国拍在线精品视频免费观看| 野花香在线视频免费观看大全| 亚洲av无码专区在线观看下载 | 久久九九兔免费精品6| 两个人www免费高清视频| 男女猛烈xx00免费视频试看| 亚洲中文无码永久免费| 亚洲校园春色另类激情| 亚洲国产成人在线视频| 天天爽亚洲中文字幕| 亚洲国产日韩视频观看| 亚洲精品无码专区在线播放| 亚洲精品国产国语| 国产成人精品亚洲一区| 女bbbbxxxx另类亚洲| 人碰人碰人成人免费视频| 免费一区二区三区在线视频| 羞羞漫画页面免费入口欢迎你| 国产青草亚洲香蕉精品久久| 成人福利在线观看免费视频| 本免费AV无码专区一区| www视频在线观看免费| 毛片视频免费观看| 久久久久国产成人精品亚洲午夜| 亚洲精品中文字幕乱码三区| 久久亚洲精品中文字幕| 亚洲av无码不卡久久| 特级aaaaaaaaa毛片免费视频| 中文字幕成人免费高清在线| 免费人成在线观看网站品爱网| 欧美好看的免费电影在线观看| 亚洲中文字幕无码久久2017 |