TADQuery with calculated field of blob type in Delphi

2k views Asked by At

I am using Anydac components to access database. TADOQuery is for selecting of data from SQL database.

One of the fields is text, but I need to display some RTF instead of this text (same text but with highlighted words, etc). I tried to create calculated field of BLOB type and fill it with correct value (original text from DB + some processing) in OnCalcFields event of TADQuery. But it doesn't work. I get AV on start of app:

"Field 'xxx' cannot be a calculated or lookup field.".

If I change FieldKind property to fkInternalCalc (default value is fkCalculated) then app starts, but then I get AV at OnCalcFields when try to set value:

"Dataset not in edit or insert mode."

If I define calculated string field (instead of BLOB field), then everything is ok, but string type has another problem. For string type I have to provide Size property limiting max size of the text. And if I use value above 64k, for example 67000, I get AV when try to assign value (even short value!) at OnCalcFields event handler:

Project xxx.exe raised exception class $C0000005 with message "access violation at 0x004094fc: read of address 0xfffffffc".

So, I can create neither calculated BLOB field nor calculated string field. (It is limited in max size and there is no information what maximum size is really safe. I found problem with size >64k, but not sure it will be stable with smaller blocks.)

Any ideas what I am doing wrong?

Update: At moment I have implemented it in a different way. I replace data on presentation layer, but it is just a workaround and question is still here. Is it possible to use calculated fields of BLOB type in Delphi (preferably with Anydac TADQuery)? Is there any information regarding to limitations on calculated fields of string type (or maybe someone has experience how to avoid them)?

procedure TDBDM.CommentsCalcFields(DataSet: TDataSet);
begin
  CommentsHighlighted.AsString := 'test';
end;

So, TADQuery has some SQL query, some fields defined + 1 calculated field of BLOB type + OnCalcFields event handler (code is above). It generates AV when I start app (and try to open query). Other things I tried were described earlier.

0

There are 0 answers