Page 1 of 1

ORABLOB Failure

Posted: Fri 02 Dec 2011 16:46
by Olivier Tailler
Hi,

I Load a stream into a ORACLE BLOB Field.
Loading into database seems to be good (no errors).
When I try to read the BLOB FIELD, I get Epic Fail.

Here my code :

Code: Select all

    CommandText := 'UPDATE MYTABLE SET MyFieldName = :pMyFieldName WHERE...';
    if (myObject  nil) then begin
      wStream := TMemoryStream.Create;
      try
        myObject.SaveToStream(TStream(wStream));
        wStream.Seek(0,SoFromBeginning);
        {$IFDEF SQLSERVER}
        Params.ParamByName('pMyFieldName').LoadFromStream(wStream, ftBlob);
        {$ENDIF}
        {$IFDEF ORACLE}
        Params.ParamByName('pMyFieldName').ParamType := ptInput;
        Params.ParamByName('pMyFieldName').DataType := ftOraBlob;
        Params.ParamByName('pMyFieldName').LoadFromStream(wStream, ftOraBlob);
        {$ENDIF}
        wStream.Seek(0, SoFromBeginning);
      finally
        wStream.Free;
      end;
    end else begin
      Params.ParamByName('pMyFieldName').DataType := ftBlob;
      Params.ParamByName('pMyFieldName').Value := NULL;
    end;
    Execute;
PS: I don't want to use :

Code: Select all

wDataSet.CommandText := 'SELECT MyFieldName FROM MYTABLE WHERE...';
wDataset.Open;
wDataset.Edit;
TBlobField(wDataset.FieldByName('STREAM')).LoadFromStream(wstream);
wDataset.Post;
wDataset.ApplyUpdates(-1);
wDataset.Close;
ODAC Version : 6.70.0.43 for Delphi 2009

Posted: Tue 20 Dec 2011 11:39
by bork
Hello

I cannot reproduce your issue neither with ODAC 6.70.0.43, nor with the latest ODAC version. If you can insert BLOB data to database correctly and get error on reading BLOB data from the database, you should provide us the piece of code that causes the error – the piece of code that performs reading BLOB data.

Posted: Tue 20 Dec 2011 15:35
by Olivier Tailler
Hello,

myObject's size is not 0 but BLOB's size is 0 so I think the problem come from writing.

Setting the property "ResolveToDataSet" of the TDataSetProvider to True solve the problem: the writed BLOB's size is correct.

Code: Select all

TDataSetProvider.ResolveToDataSet := True;
Thank you.

Posted: Thu 22 Dec 2011 10:59
by bork
Hello

TDataSetProvider is usually used with dbExpress drivers. Also TDataSetProvider can be used with ODAC, but it will be better if you send me a simple sample project with your usage specifics of TDataSetProvider, that reproduces this issue at borism*devart*com. This sample should perform two actions:
- Save BLOB to a database by a stream
- Try to load BLOB from the database (and reproduce the issue with the "Epic Fail")