| 查询CLOB的PL/SQL函数:getclob create or replace function getclob( table_name in varchar2, field_id in varchar2, field_name in varchar2, v_id in number, v_pos in number) return varchar2 is lobloc clob; buffer varchar2(32767); amount number := 2000; offset number := 1; query_str varchar2(1000); begin query_str :='select '||field_name||' from '||table_name||' where '||field_id||'= :id '; --initialize buffer with data to be found EXECUTE IMMEDIATE query_str INTO lobloc USING v_id; offset:=offset+(v_pos-1)*2000; --read 2000 varchar2 from the buffer dbms_lob.read(lobloc,amount,offset,buffer); return buffer; exception when no_data_found then return buffer; end; |
l 用法说明:
用select getclob(table_name,field_id,field_name,v_id,v_pos) as
partstr from dual;
可以从CLOB字段中取2000个字符到partstr中,
编一个循环可以把partstr组合成dbms_lob.getlength(field_name)长度的目标字符串。
二、对于在其他不同的开发环境,例如vc,vb,pb,java等环境下对lob的处理,处理方法不尽相同,在这里将简要举几个例子来说明不在oracle开发环境下对lob的处理。
(一) 在pb中的处理
| exampler 2. string ls_path,ls_filename,ls_jhdh long ll_num,ll_count,rtn blob ole_blob ll_num=dw_lb.getrow() if ll_num>0 then ls_jhdh=dw_lb.object.ct_njhdh[ll_num] select count(*) into :ll_count from sj_jh_jhfjb where ct_jhdlxbh='1' and ct_jhdh=:ls_jhdh and ct_jdlxbh=:is_jdlx; if ll_count>0 then rtn=messagebox("提示","是否要修改此附件",question!,yesno!,1) if rtn=1 then SELECTBLOB ct_jhfjnr INTO le_blob from sj_jh_jhfjb where ct_jhdlxbh='1' and ct_jhdh=:ls_jhdh and ct_jdlxbh=:is_jdlx; ole_1.objectdata =ole_blob If ole_1.activate(offsite!) <> 0 Then Messagebox("OLE Activate","不能激活") Return -1 end If end if else messagebox("提示","没有附件") end if end if |

