在oracle中
下面是對lob數據類型的簡單介紹
blob:二進制lob
clob:字符lob
bfile:二進制文件;存貯在數據庫之外的只讀型二進制數據
nclob
對於如何檢索和操作這些lob數據一直是oracle數據庫開發者經常碰到的問題
oracle中可以用多種方法來檢索或操作lob數據
其他的方法包括使用api(application programming interfaces)應用程序接口和oci(oracle call interface)oracle調用接口程序
一
dbms_lob包功能強大
在dbms_lob包中內建了read()
對於pl/sql
example
動態PL/SQL
修改CLOB的PL/SQL過程
create or replace procedure updateclob(
table_name in varchar
field_id in varchar
field_name in varchar
v_id in number
v_pos in number
v_clob in varchar
is
lobloc clob;
c_clob varchar
amt binary_integer;
pos binary_integer;
query_str varchar
begin
pos:=v_pos*
amt := length(v_clob);
c_clob:=v_clob;
query_str :=
EXECUTE IMMEDIATE query_str INTO lobloc USING v_id;
dbms_lob
commit;
exception
when others then
rollback;
end;
l /用法說明
在插入或修改以前
然後調用以上的過程插入大於
如果需要插入大於
查詢CLOB的PL/SQL函數
create or replace function getclob(
table_name in varchar
field_id in varchar
field_name in varchar
v_id in number
v_pos in number) return varchar
is
lobloc clob;
buffer varchar
amount number :=
offset number :=
query_str varchar
begin
query_str :=
EXECUTE IMMEDIATE query_str INTO lobloc USING v_id;
offset:=offset+(v_pos
dbms_lob
return buffer;
exception
when no_data_found then
return buffer;
end;
l 用法說明
用select getclob(table_name
可以從CLOB字段中取
編一個循環可以把partstr組合成dbms_lob
二
(一) 在pb中的處理
exampler
string ls_path
long ll_num
blob ole_blob
ll_num=dw_lb
if ll_num>
select count(*) into :ll_count from sj_jh_jhfjb where ct_jhdlxbh=
if ll_count>
rtn=messagebox(
if rtn=
SELECTBLOB ct_jhfjnr INTO le_blob from sj_jh_jhfjb where ct_jhdlxbh=
ole_
If ole_
Messagebox(
Return
end If
end if
else
messagebox(
end if
end if
(二)在vb中的處理
在vb中處理大對象
下面這段程序可以將一個文件(文本文件
需要兩個commandbutton
cmd
cmd
一個cmddialog控件
同時需要創建一張表t_demo(字段id 類型 number
exmple
Option Explicit
Dim rn As ADODB
Public Function CreateDataSource(DataSource As String
On Error GoTo DbConErr:
Set rn = New ADODB
With rn
End With
CreateDataSource = True
Exit Function
DbConErr:
CreateDataSource = False
End Function
Private Sub cmdRead_Click()
Dim rs As New ADODB
rs
rs
rs
rs
rs
ComDlgDir
ComDlgDir
ComDlgDir
Call BlobToFile(rs
Set rs = Nothing
Exit Sub
Set rs = Nothing
End Sub
Private Sub cmdsave_Click()
Dim rs As New ADODB
rs
rs
rs
rs
rs
rs
ComDlgDir
ComDlgDir
rs
If ComDlgDir
Call FileToBlob(rs
rs
End If
Set rs = Nothing
Exit Sub
Set rs = Nothing
End Sub
Private Sub Form_Load()
If Not CreateDataSource(
MsgBox
End If
End Sub
fld As ADODB
Dim fnum As Integer
Dim tmp() As Byte
If (fld
Err
End If
If Dir$(filename) =
fnum = FreeFile
Open filename For Binary As fnum
bytesleft = LOF(fnum)
Do While bytesleft
bytes = bytesle
From:http://tw.wingwit.com/Article/program/Oracle/201311/17733.html