Bug while writing a file content to a long raw field?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
nunobsa
Posts: 2
Joined: Thu 27 Aug 2009 13:01

Bug while writing a file content to a long raw field?

Post by nunobsa » Thu 27 Aug 2009 13:19

Hello

I think I found a bug in ODAC.

The environment I am working on is:
Borland Delphi 7
ODAC 6.80.0.48
Oracle Database:
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production

Here is the problem.
If in the TOraSession Options I set the ConvertEOL option to true, when I save the content of a file into a long raw field, the content of the file changes (the carriage return are converted), and I don't think it should.

Example Code (save to database):

with FQuery do begin
SQL.Clear;
SQL.Text := 'INSERT INTO FILESTABLE(ID,FILENAME,FILECONTENT) VALUES(:ID, :NAME, :CONTENT)';
ParamByName('ID').AsInteger := 123;
ParamByName('NAME').AsString := 'ABC';
ParamByName('CONTENT').LoadFromFile(aFileName, ftBlob);
Execute;
end;


Example Code (load from database):

with FQuery do begin
SQL.Clear;
SQL.Text := 'SELECT * FROM FILESTABLE WHERE ID = :ID';
ParamByName('ID').AsInteger := 123;
Execute;
blob := GetBlob('FILECONTENT');
blob.SaveToFile(aFileName);
end;


blob is a TBlob.

The content of the file loaded from the db is different from the content of the file saved to it.
It seems that the bug is in the "Save to Database" part, since that I could load from database files that were already there.

The FILESTABLE was created with the following SQL.

CREATE TABLE FILESTABLE(
ID NUMBER NOT NULL,
FILECONTENT LONG RAW,
FILENAME VARCHAR2 (255),
CONSTRAINT PK_FILESTABLE
PRIMARY KEY ( ID ) ) ;


Is it a bug or am I doing something wrong?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 28 Aug 2009 08:32

We have fixed this problem. The fix will be included in the next build of ODAC.

nunobsa
Posts: 2
Joined: Thu 27 Aug 2009 13:01

Post by nunobsa » Fri 28 Aug 2009 09:12

Thank you!

I've found a workaround for the moment:


(FQuery.Connection.Options as TOraSessionOptions).ConvertEOL := false;
ParamByName('CONTENT').LoadFromStream(Stream, ftBlob);
Execute;
(FQuery.Connection.Options as TOraSessionOptions).ConvertEOL := true;

Post Reply