synopse / mORMot

Synopse mORMot 1 ORM/SOA/MVC framework - Please upgrade to mORMot 2 !
https://synopse.info
788 stars 325 forks source link

Implementation of ColumnBlobToStream and ColumnBlobFromStream in TOleDBStatement #405

Closed algalg closed 2 years ago

algalg commented 3 years ago

Implementation of ColumnBlobToStream and ColumnBlobFromStream in TOleDBStatement Implementation of TransactionIsolationLevel property in TOleDBConnectionProperties

algalg commented 3 years ago

I use this on MSSQL Server. Unfortunately I don't think there is any way to tell that the select query is for updating the content. This odd construction is what MS documents as way of working with large data https://docs.microsoft.com/en-us/sql/connect/oledb/ole-db-how-to/set-large-data-ole-db?view=sql-server-ver15

This is how it is used in the code:

  objectid := '123';
  FileName := 'C:\TheBigContentFile.pdf';

  FileStrm := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone);
  try
    FProviderSession.ExecuteNoResult('INSERT INTO CONTENT_TABLE (id, blobfiled) ', [objectid, 'NULL']);

    Stmt :=  Connection.NewStatementPrepared('SELECT blobfiled FROM CONTENT_TABLE WHERE id = ?', true, true);
    Stmt.ForceBlobAsNull := false;
    Stmt.Bind([ObjectID]);
    Stmt.ExecutePrepared(true);
    SQLDBRows := Stmt;

    SQLDBRows.Step();
    SQLDBRows.ColumnBlobFromStream(0, FileStrm);
  finally
    FileStrm.Free;
  end;
synopse commented 2 years ago

No other proposal after a few months waiting for an alternative.

Please reopen if needed.