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
  PSQLTable1.Edit;
  if PSQLTable1.State = dsEdit then
  begin
    Stream1 := PSQLTable1.CreateBlobStream(FieldByName('Notes', bmReadWrite);
    try
// Move to byte 60
      Stream1.Seek(60, 0);
// Delete from current position (60) to the end of the stream.
      Stream1.Truncate;
      PSQLTable1.Post;
    finally
      Stream1.Free;
    end;
  end;
end;