Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: OCITransStart Problem, starting simple readonly transaction
On 3 Jun 2002 12:11:39 -0700, boileaub_at_hotmail.com (David B) wrote:
>Kevin English <kenglish_at_4csoftware.com> wrote in message
>> >According to the Oracle OCI documentation, to start a read only
>> >transaction, I need to explicitly start the transaction using
>> >OCITransStart()
>> >
>> >So I added the following code for the read only local transaction :
>> >
>> >checkStatus(
>> > OCITransStart( _serviceContext,
>> >
>> >DbEnvOracle::getInstance().getErrorHandle(),
>> > 0,
>> > OCI_TRANS_NEW | OCI_TRANS_READONLY )
>> >);
>> >
>> >Running my application with this causes checkStatus() to fail ...
>> >OCITransStart return OCI_INVALID_HANDLE
>> >I know that _serviceContext and the error handle should be valid since
>> >my application works fine without OCITransStart().
>> >
>> >Do I have to manually allocate a transaction handle ? or am I missing
>> >a step...
>> Hi,
>> Have you allocated a transaction handle and set it into the
>> service context, using OCIAttrSet(...OCI_ATTR_TRANS) ?
>> Without doing that you will get the OCI_INVALID_HANDLE error from
>> OCITransStart().
>> Cheers
>> Kevin English
>>
>
>I added the OCITrans allocation but when I set it in the
>_serviceContext, the status return the ORA-24336: invalid result set
>descriptor. However, txn is being initialized and in not null at the
>time of the OCIAttrSet()
>
>OCITrans* txn = 0;
>
>sword status = OCIHandleAlloc(
> DbEnvOracle::getInstance().getEnv(),
> (dvoid**)&txn,
> OCI_HTYPE_TRANS,
> 0,
> 0
>);
>
>status = OCIAttrSet(
> _serviceContext,
> OCI_HTYPE_SVCCTX,
> txn,
> 0,
> OCI_ATTR_TRANS,
> DbEnvOracle::getInstance().getErrorHandle()
>);
>
>I create the connection with the server using the OCILogon() ( the
>simplified method ), do I have to manually create the server, session
>and service context by hand ? Or maybe I missed something...
Hi again,
If you use OCILogon(), then the service context, server and user
session handles are all read only and you cannot modify
any attributes of any of them including the transaction handle.
See Chapter 2 "Initialization, Connection, and Session Creation" in the "Oracle Call Interface Programmer's Guide".
Bye
Kevin English
Posted Via Usenet.com Premium Usenet Newsgroup Services
![]() |
![]() |