Page 1 of 1

Can TOraSession use the connection of a Pro*C program?

Posted: Tue 03 Aug 2010 16:31
by Orange
We have a Pro*C DLL which connects to Oracle. We would like to use this connection with our Delphi 5 ODAC TOraSession, so we have only one connection instead of two. In the DLL I export a global:

sqllda(&OracleLda);

In Delphi I get OracleLda pointer with an extern function. I was under the impression that we could assign this LDA to the TOraSession.LDA, but the field is read-only.

Is there another way ?

Tx.

Posted: Thu 05 Aug 2010 16:06
by bork
Hello

The connection LDA handle is used in old Oracle versions (until Oracle 7). Since Oracle 8 the OCISvcCtx connection handle is used the OCISvcCtx connection handle. You can get OCISvcCtx from your Pro*C DLL and assign it to TOraSession.

Posted: Thu 05 Aug 2010 20:33
by Orange
I have tried with the LDA property, but the property in TOraSession is read-only and cannot be assigned. Idem with OraSvsCtx. So it does not seems possible.

You have code sample ?

Posted: Thu 05 Aug 2010 20:42
by Orange
Just tested OCISvcCtx, its not read only, so I will try this. Tx.

Posted: Fri 06 Aug 2010 22:19
by Orange
:D Works indeed! Here is the Pro*C code to export whas is needed to share the connexion:

Code: Select all


#include 
#include 

OCISvcCtx* STDCALL GetOciSvcCtx() // (simplified. do after connect
{
	OCISvcCtx* svchp; // OCI Service context handle

	SQLSvcCtxGet(0,0,-1,&svchp);

	return svchp;
}

Posted: Mon 09 Aug 2010 11:49
by bork
It is good to see that this problem has been solved. If any other questions come up, please contact me.