ODAC讀寫BLOB
var tf:TBlob; ts:TMemoryStream; /////显示原始上传图像 DataModule1.OraQuery1.SQL.Clear; DataModule1.OraQuery1.SQL.Add('select tp from base where id='+QuotedStr(RzDBEdit2.Text)); DataModule1.OraQuery1.Open; if (not DataModule1.OraQuery1.Eof) then begin DataModule1.OraQuery1.First ; tf:=DataModule1.OraQuery1.GetBlob('tp' ) ; if tf.Size>0 then begin tf.SaveToFile( 'c:\1.jpg'); Image1.Picture.LoadFromFile('c:\1.jpg') ; end; end; //写数据: DataModule1.OraSQL1.SQL.Clear ; DataModule1.OraSQL1.SQL.Add('insert into sample(XM,TP) values (:XM,EMPTY_BLOB()) returning TP into :TP') ; //DataModule1.OraSQL1.SQL.Add('update sample set TP=EMPTY_BLOB() where XM=:XM returning TP into :TP') ; DataModule1.OraSQL1.Prepare ; DataModule1.OraSQL1.ParamByName('XM').AsString := '123' DataModule1.OraSQL1.ParamByName('TP').ParamType :=ptInput; ts:=TMemoryStream.Create ; if tf.Size>0 then tf.SaveToStream(ts) ; DataModule1.OraSQL1.ParamByName('TP').AsOraBlob.LoadFromStream (ts); ts.Free ; DataModule1.OraSQL1.Execute ;