zoukankan      html  css  js  c++  java
  • 写入和读取LOB类型的对象

    ====写入数据============

    create or replace procedure addWaterFall
    is
    directions clob;
    amount binary_integer;
    offset integer;
    first_direction varchar2(1000);
    more_direction varchar2(1000);
    begin
    --删除已经存在的同名记录
    delete from waterfalls t where t.falls_name='Munising Falls';

    --插入新行,并创建文件定位符
    insert into waterfalls(falls_name,falls_direction)
    values ('Munising Falls',empty_clob());

    --取出文件定位符
    select falls_direction into directions from waterfalls t where t.falls_name='Munising Falls';

    --打开lob
    dbms_lob.open(directions,dbms_lob.lob_readwrite);

    --写入数据
    first_direction :='direction ttttttttttt';
    amount :=length(first_direction);
    offset :=1;
    dbms_lob.write(directions,amount,offset,first_direction);

    --追加数据
    more_direction :='more fffffffffff';
    amount :=length(more_direction);
    dbms_lob.writeappend(directions,amount,more_direction);

    --关闭lob
    dbms_lob.close(directions);
    end;

    ========读取数据================

    create or replace procedure readLobTest
    is
    amountEveryTime constant binary_integer := 2;
    readSize binary_integer := amountEveryTime;
    directions clob;
    resultStr varchar2(1000);
    perStr varchar2(299);
    offset integer;

    begin
    --提取定位符
    select t.falls_direction into directions from waterfalls t where t.falls_name='Munising Falls';

    --设置偏移量
    offset :=1;

    --读取clob
    while(readSize = amountEveryTime)
    loop
    dbms_lob.read(directions,readSize,offset,perStr);
    offset := offset+readSize;
    resultStr :=concat(resultStr,perStr);
    end loop;
    dbms_output.put_line(resultStr);
    end;

  • 相关阅读:
    UVA10740 Not the Best (K短路)
    UVA10967 The Great Escape(最短路)
    UVA 10841 Lift Hopping in the Real World(dijkstra)
    U盘启动的PE系统的制作方法
    让远程桌面支持多用户
    学习的书的下载地址
    刚安装完的vs2008写的ajax应用提示sys未定义
    AS3 Libs
    禁用触发器
    Microsoft .NET 类库开发的设计准则
  • 原文地址:https://www.cnblogs.com/moonfans/p/4275219.html
Copyright © 2011-2022 走看看