#1 2012-01-31 15:05:10

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 69
Website

How to return through a TMemoryStream TSQLRequest?

Hello administrator,
Can you create within SynSQLite3.pas a function to return a TMemoryStream directly.
It would be like:
TSQLRequest.FieldBlob function (Col: integer): RawByteString;
something like:
TSQLRequest.FieldBlob function (Col: integer): TMemoryStream;

Or someone shows me how to create a function to it.

I appreciate any help.

Offline

#2 2012-01-31 15:24:14

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: How to return through a TMemoryStream TSQLRequest?

Just use TRawByteStringStream.Create(aRequest.FieldBlob) - it will return a read-only TStream containing the content.

Do not forget to Free this TRawByteStringStream instance when you do not need it any more.

TRawByteStringStream is defined in SynCommons.pas.

Offline

#3 2012-01-31 16:52:51

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 69
Website

Re: How to return through a TMemoryStream TSQLRequest?

Thank you,

I solved this problem with your help.

You can show me an example of how to write in a SQLite TMemoryStream.

Something like:

procedure UpdateBlob(const SQL: string; BlobStream: TMemoryStream);
begin
  ...
end;

Offline

#4 2012-01-31 17:06:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: How to return through a TMemoryStream TSQLRequest?

Something like:

procedure UpdateBlob(DB: TSQLite3DB; const SQL: string; BlobStream: TMemoryStream);
var Req: TSQLRequest;
begin // SQL statement should have BLOBFIELD=? 
  Req.Prepare(DB,StringToUTF8(SQL));
  Req.Bind(1,BlobStream.Memory,BlobStream.Size);
  Req.Execute;
end;

I've added new TSQLRequest.FieldBlobToStream and TSQLRequest.Bind(TCustomMemoryStream) methods, if it can help you.
See http://synopse.info/fossil/info/40f8985541

Offline

#5 2012-01-31 18:54:26

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 69
Website

Re: How to return through a TMemoryStream TSQLRequest?

Thank you!

What I wanted was to save and retrieve a component Tkbmmentable with the data in the SQLite and now I get with these changes you made in synSQLite3 unit.

This is an excellent project.

Offline

Board footer

Powered by FluxBB