Hi.
I am trying to read/write from/to RichMemo as a Blob.
Reading from db and writing to RichMemo works fine (btRead)
but writing to db from RichMemo (btWrite) fails with StackOverflow.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, db, sqldb, IBConnection, Forms, Controls, Graphics,
Dialogs, StdCtrls, RichMemo;
type
{ TForm1 }
TForm1 = class(TForm)
btRead: TButton;
btWrite: TButton;
DataSource1: TDataSource;
IBConnection1: TIBConnection;
RichMemo1: TRichMemo;
RichMemo2: TRichMemo;
SQLQuery1: TSQLQuery;
SQLTransaction1: TSQLTransaction;
procedure btReadClick(Sender: TObject);
procedure btWriteClick(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.btReadClick(Sender: TObject); //this works fine
var stream: TMemoryStream;
begin
stream:= TMemoryStream.Create;
try
SQLQuery1.Close;
SQLQuery1.SQL.Text:= 'select TEXTBLOB from PRIKAZY where PORCIS = 5';
SQLQuery1.Open;
TBlobField(SQLQuery1.FieldByName('TEXTBLOB')).SaveToStream(stream);
stream.Position:= 0;
RichMemo1.Lines.LoadFromStream(stream);
finally
stream.Free;
end;
end;
procedure TForm1.btWriteClick(Sender: TObject); //does not work
var stream: TMemoryStream;
begin
IBConnection1.Connected:= true;
SQLTransaction1.Active:= true;
stream:= TMemoryStream.Create;
try
RichMemo2.Lines.SaveToStream(stream);
stream.Position:= 0;
SQLQuery1.Open;
SQLQuery1.SQL.Text:= 'update PRIKAZY set TEXTBLOB=:TEXTBLOB where PORCIS = 5'; //here it fails
SQLQuery1.ParamByName('TEXTBLOB').LoadFromStream(stream,ftMemo);
SQLQuery1.ExecSQL;
SQLTransaction1.Commit;
SQLQuery1.Close;
finally
stream.Free;
end;
end;
Assembler:
DB$_$TMASTERDATALINK_$__$$_CHECKBROWSEMODE
00000001001BA940 53 push %rbx
00000001001BA941 488d6424e0 lea -0x20(%rsp),%rsp
00000001001BA946 4889cb mov %rcx,%rbx
00000001001BA949 488b4b30 mov 0x30(%rbx),%rcx
00000001001BA94D e87e33ffff callq 0x1001adcd0 <DB$_$TDATASET_$__$$_GETACTIVE$$BOOLEAN> //here it fails
00000001001BA952 84c0 test %al,%al
00000001001BA954 7409 je 0x1001ba95f <DB$_$TMASTERDATALINK_$__$$_CHECKBROWSEMODE+31>
00000001001BA956 488b4b30 mov 0x30(%rbx),%rcx
00000001001BA95A e8b142ffff callq 0x1001aec10 <DB$_$TDATASET_$__$$_CHECKBROWSEMODE>
00000001001BA95F 90 nop
What I am doing wrong?