ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle 提取blob对象

oracle 提取blob对象

原创 Linux操作系统 作者:nevgup 时间:2010-11-12 19:01:24 0 删除 编辑
1:创建目录, 创建存放数据的目录

       create directory lcc_dir as 'C:\dir';

2:创建用户

       create user lcc identified by 123;

3:给用户授权

       grant read, write on directory lcc_dir to lcc;

4:创建提取过程

      create or replace procedure download_blob(srcname varchar2, dstname varchar2) as

           mount binary_integer := 32767;

           fbuffer raw(32767);

           utlfile utl_file.file_type;

           dumpfile blob;

           pos integer := 1;

           len binary_integer; 

       begin

           select blob_file into dumpfile from blob_tb where data_name = srcname;

           len := dbms_lob.getlength(dumpfile); 

           utlfile := utl_file.fopen('LCC_DIR', dstname, 'wb', 32767);

           while pos < len loop

                 dbms_lob.read(dumpfile, mount, pos, fbuffer);

                 utl_file.put_raw(utlfile, fbuffer, true);

                 pos := pos + mount;

           end loop;

            utl_file.fclose(utlfile);

      end;   

/

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24751301/viewspace-678030/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-11-12

  • 博文量
    3
  • 访问量
    4202