Delphi 数据存储到oracle数据库TBLOB/TCLOB的方法 包括JSON串的解析

保存可以用下面的方法

var

   Stream: TMemoryStream;

begin

Stream := TMemoryStream.Create;
jitems.SaveTo(Stream);
Stream.Position := 0;

TBlobField(FieldByName('DATA_PACKET')).LoadFromStream(Stream);

 

Stream.Free;

若是要读取

var
clGT: string;
jitems: ISuperObject;
tt: TSuperArray;
i: Integer;
F, U: ArrayDouble;

begin

SQL.Add('select dbms_lob.substr(DATA_PACKET) as DATA_PACKET from PDM_MO_POWERDIAGRAM_TEMPLATE where IS_TEMPLATE=1 AND WELL_ID=' + Quotedstr(DXID));
clGT := FieldByName('DATA_PACKET').AsString;
jitems := SO(clGT);
tt := jitems.AsArray;
SetLength(F, tt.Length);
SetLength(U, tt.Length);
for i := 0 to tt.Length - 1 do
begin
F[i] := tt[i]['Work'].AsDouble; 
U[i] := tt[i]['Move'].AsDouble; 
end;

 

posted @ 2019-12-20 15:15  南国之恋  阅读(622)  评论(0编辑  收藏  举报