OCI_INVALID_HANDLE with TSmartQuery saving to a BLOB

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Guest

OCI_INVALID_HANDLE with TSmartQuery saving to a BLOB

Post by Guest » Thu 31 Aug 2006 11:40

Hello,

I've got some trouble here... :)

I have a TSmartQuery opened w/ a SQL query
(Default properties, except CacheLobs is set to false, SmartRefresh to True, UpdatingTable to 'PAGES'):

SELECT FAX.PAGES.ROWID,
FAX.PAGES.*,
FAX.PAGE_VERSION(FAX.PAGES.PAGE_ID) AS PAGE_VERSION,
FAX.V_PATIENTS.STUDY_LONG_DESCRIPTION,
FAX.V_PATIENTS.CENTRE_SPONSOR_NAME,
FAX.V_PATIENTS.PATIENT_DESCRIPTION
FROM FAX.PAGES
LEFT JOIN FAX.V_PATIENTS ON PAGES.PATIENT_ID=V_PATIENTS.PATIENT_ID
ORDER BY FAX_IN_ID, FAX_PAGE

where PAGES is a table, PAGE_VERSION is a function and V_PATIENTS is a view. The database is an Oracle 9i, and I am logged as "FAX" user.

When I try to update a BLOB from the PAGES table of this query, it works the first time, but the second... it gives the following message when posting the record:

OCI_INVALID_HANDLE

Do you know what could be wrong, or how could I correct this?

sBLOB := frmOracle.sqlPages.CreateBlobStream(frmOracle.sqlPages.FieldByName('PDF'), bmWrite);
if PDF.SaveToStream(sBLOB)=0 then Raise Exception.Create('Error saving image to database');
sBLOB.Free;
frmOracle.sqlPages.Post; <- Returns OCI_INVALID_HANDLE

Thanks.

PS: By the way, this is the complete procedure:

procedure TfrmCurrentPage.butPageApplyClick(Sender: TObject);
Var s: TVirtualTable;
BMP32 : TBitmap32; BMP : TBitmap;
PDF : TiSEDQuickPDF;
sBLOB : TStream;
begin
BMP := Nil; sBLOB := Nil;
Try
BMP32 := frmCurrentPageDisplay.ivPage.Bitmap;
BMP := TBitmap.Create;
BMP32.AssignTo(BMP);
BMPToPDF(BMP, PDF);
frmOracle.sqlPages.Edit;
Try
s := cdbcbSubject.Selection;
frmOracle.sqlPages.FieldByName('ROTATED').AsInteger := FRotated;
frmOracle.sqlPages.FieldByName('FLIPPED_UD').AsString := IIf(FFlippedUD, 'Y', 'N');
frmOracle.sqlPages.FieldByName('FLIPPED_RL').AsString := IIf(FFlippedRL, 'Y', 'N');
if s.Eof then frmOracle.sqlPages.FieldByName('PATIENT_ID').AsVariant := Null
else frmOracle.sqlPages.FieldByName('PATIENT_ID').AsInteger := s.FieldByName('PATIENT_ID').AsInteger;
frmOracle.sqlPages.FieldByName('CRF_PAGE').AsInteger :=
spinPageCRFPage.AsInteger;
frmOracle.sqlPages.FieldByName('SUBPAGE').AsInteger :=
spinPageCRFSubpage.AsInteger;
frmOracle.sqlPages.FieldByName('PAGE_STATUS_ID').AsInteger :=
bcbPageStatus.ID;
sBLOB := frmOracle.sqlPages.CreateBlobStream(frmOracle.sqlPages.FieldByName('PDF'), bmWrite);
if PDF.SaveToStream(sBLOB)=0 then Raise Exception.Create('Error saving image to database');
sBLOB.Free;
// PDF.SaveToFile('c:\pdf.pdf'); <- without comment, PDF object is properly saved here...
frmOracle.sqlPages.Post; // <- Returns OCI_INVALID_HANDLE. No error if I don't save to the blob (removing the three lines above)
except
frmOracle.sqlPages.Cancel;
end;
finally
FreeNotNil (sBLOB);
FreeNotNil (PDF);
FreeNotNil (BMP);
DisplayChange(Self);
end;
end;

Flub
Posts: 9
Joined: Thu 01 Jun 2006 14:38

The "guest" is me...

Post by Flub » Fri 01 Sep 2006 09:10

I think my session expired when I added the post yesterday.
So now the "guest" has a name... It's me...

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

Post by Plash » Mon 04 Sep 2006 14:04

We cannot reproduce the problem. If it is possible send to ODAC support address complete sample that demonstrates the problem and include script to create server objects.

Post Reply