EPUB | CHM | PDF

Example: State, Seek, Truncate

Top Previous Next

The following example deletes the stream from position 60 within the blob stream to the end.

procedure TForm1.Button1Click(Sender: TObject);
var
  Stream1: TBlobStream;
begin
  MySQLTable1.Edit;
  if MySQLTable1.State = dsEdit then
  begin
    Stream1 := MySQLTable1.CreateBlobStream(FieldByName('Notes', bmReadWrite);
    try
      Stream1.Seek(60, 0); // Move to byte 60
      Stream1.Truncate;    // Delete from current position (60) to end of stream.
      MySQLTable1.Post;
    finally
      Stream1.Free;
    end;
  end;
end;