I think you could create a TMemoryStream, and use its Write-Method
https://www.freepascal.org/docs-html/current/rtl/objects/tmemorystream.write.html
In the End it really depends what alignement your packed record has.
After that it should be a simple
(note: Aircode! Not tested!)
Several errors pop up:
1) TMemoryStream.Create takes no arguments.
2) SQLQuery.ParamsByName does not exist, it shall be FieldByName
3) LoadFromStream() does not exist for FQuery
4) (MyStream, ftBlob), ftBlob is not recognized
MyStream:=TMemoryStream.Create(nil);
MyStream.Write(MyPackedRecord, 32);
SQLQuery.ParamsByName('MyBlobData').LoadFromStream(MyStream, ftBlob);
SQLQuery.ExecSQL;
And reading it from the db is the other way round (Read_method of MemoryStream)
I have not used streams in my programming earlier so I have to consult web pages...
The example given does not work...
And this example is the wrong way, my problem here is to
read from the database, not to write to it.
That will be the task for the next method I will write.
I understand how to read bytes from and write to a memory stream, but not how to actually write the stream with data from a Query..
In the previous query calls in my code it is a simple assignment from the query to a variable specifying the AsSomething.
But In this case, how can it be done???
I tried to google it but find only non-working Delphi examples...
What do I do with the below code to READ data from the query into the TS.MeasSettings record?
//Alternate solution using memory stream:
MStr:=TMemoryStream.Create;
//How to get the data from FQuery into the memory stream?
MStr.Write(FQuery.FieldByName('MeasSettings'), SizeOf(TSSMeasSettings)); //Does this really work?
MStr.Write(FQuery.FieldByName('MeasSettings').AsBytes, SizeOf(TSSMeasSettings)); //Or is this how it must be done?
//Move data from stream to record:
MStr.Read(TS.MeasSettings, SizeOf(TSSMeasSettings));
MStr.Free;
It does not throw compile errors, but since I do not have a write to database method yet I cannot check if the correct data is stuffed into the database and read back...
And it seems like there is a problem to use memory stream for writing to the database blob field..