LOB-Problem "Invalid Handle"

Hi,

we've finally upgraded an AppServer-application, that encapuslate all ORACLE-operations into DB. The application is very flexible; the traffic is sent as a Delphi-ClientDataset and will be inserted/updated into the DB. As the ClientDataset Comes to AppServer, the contents will be made into insert/update-SQLs using TOracleQuery; all parameters will be created and filled in code in AppServer. Of course, the AppServer uses many concurrent sessions from several Clients.

Here is some (of course simplier as real; but the LOB-part is copied) example of code:

s := cds.Fields.AsString;

Lob := TLobLocator.CreateTemporary(db_dest, otCLOB, false);
Lob.WriteBuffer(s[1],length(s)*SizeOf(char));

oraqry.SetComplexVariable(pdxtbl.Fields.FieldName, Lob);

oraqry.Execute;

This procedure was working good in Delphi 6 (DOA 4.0.5.0), but in the new environment (DOA 4.1.3.5) gets often an error "TLOBLocator: Invalid handle"; sometimes AppServer gets an AccessViolation 680F31CB in Modul 'OraOCIEI12.dll' when TLobLocator will be opened.

OracleClient is Version 12.1.0.2

Any ideas?

Thanks,
Peter
 
Is this a multi-threaded application? Usually these kind of unpredictable errors are caused by a problem with thread safety.
 
Yes, this is a multi-threded application ...

How can we make a safely thread?
Can we create a TCriticalSection around the Query? Or around the TLobLocator?

Why this was working in Delphi6 without Problem?
 
You can indeed try this with a TCriticalSection, but you will need to know what other thread/code conflicts with this code so that you can use the same TCriticalSection there.

The problem can also be caused by Delphi 6 / Delphi 10 compatibility issues. Most likely culprit is the difference in string/char sizes of course.
 
Back
Top