斑点为String:如何从BLOB StoredProcedure的参数转换为字符串中PostgreSQL的?

我已存储过程(从Postgres函数)型像这样的参数:

Params[0] : result = ftBlob // postgresql function = text Params[1] : 1 = ftString Params[2] : 2 = ftInteger Params[3] : 3 = ftInteger

我的代码是这样的:

procedure TForm1.Button1Click(Sender: TObject); var ResultStr: TResultStr; BlobField: TBlobField; bStream: TStream; DataSet: TDataSet; StoredProc: TSQLStoredProc; begin sp01.Close; sp01.Params[1].AsString := '2010/2011'; sp01.Params[2].AsInteger := 2; sp01.Params[3].AsInteger := 1; sp01.ExecProc; if sp01.ParamByName('result').Value.IsBlob then begin BlobField := StoredProc.ParamByName('result') as TBlobField; bStream := sp01.CreateBlobStream(BlobField, bmRead); try bStream.Read(ResultStr,sizeof(TResultStr)); finally bStream.Free; end; end; ShowMessage(ResultStr.Hasil); end;

问题是,我怎么想得到的结果(BLOB)成为字符串?

--------------解决方案-------------

我不知道是什么TResultString是,但你可以用绳子做到这一点:

var
BlobResult: string; // Changed to make clearer where changes were below
begin
// Your other code here

if sp01.ParamByName('result').Value.IsBlob then
begin
BlobField := StoredProc.ParamByName('result') as TBlobField;
bStream := sp01.CreateBlobStream(BlobField, bmRead);
try
SetLength(BlobResult, bStream.Size); // Note changes here
bStream.Read(BlobResult[1], bStream.Size); // and here
finally
bStream.Free;
end;
end;

分类:PostgreSQL的 时间:2015-03-15 人气:0
本文关键词: PostgreSQL的,德尔福XE2
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 0.721 (s). 10 q(s)