ORABLOB Failure

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Olivier Tailler
Posts: 2
Joined: Fri 02 Dec 2011 16:32

ORABLOB Failure

Post by Olivier Tailler » Fri 02 Dec 2011 16:46

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

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Tue 20 Dec 2011 11:39

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.

Olivier Tailler
Posts: 2
Joined: Fri 02 Dec 2011 16:32

Post by Olivier Tailler » Tue 20 Dec 2011 15:35

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.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Thu 22 Dec 2011 10:59

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")

Post Reply