It seems that Transparent Application Failover (TAF) is enabled for your connection. If TAF is enabled the Oracle Lientclient will reconnect you thoto the database or an alternate database if the connection between the client and the server is disruppteddisrupted. You use an OCI client and for this it is possible to register a failover callback function that is called after the client reconnects. In this callback funtionfunction you can issue the 'ALTER SESSION' command you need. But maybe you don't want to use TAF.
If your thessionthe session uses TAF then you should find out, wherrewhere it is configured. It can be configured on client side or on server side. You can check your tnsname'tnsname.oraora' file or use your 'tnsping' utlity to check your client configuration. If you find something similar to this example from Net Services Administrator's Guide
then TAF is configured because of FAILOVER_MODE=(TYPE=select)FAILOVER_MODE=(TYPE=select)
. If this is the case you should configure an appropriate conenctconnect string without TAF.
But even if no TAF is configure on client side it could be configured on server siseside for this service. So do the following query
The following example output shows that TAF will be used for (SERVICE_NAME=sales.us.example.com)(SERVICE_NAME=sales.us.example.com)
even if it is not configured on the client.
sales.us.example.com
NETWORK_NAME FAILOVER_METHOD FAILOVER_TYPE
------------------------ -------------------- --------------------
sales.us.example.com BASIC SELECT
sales3.us.example.com NONE NONE
NETWORK_NAME FAILOVER_METHOD FAILOVER_TYPE
------------------------ -------------------- --------------------
sales.us.example.com BASIC SELECT
sales3.us.example.com NONE NONE
In this case TAF will be used for (SERVICE_NAME=sales.us.example.com)(SERVICE_NAME=sales.us.example.com)
even if TAF is not configured on the client. So you have to use a service that does not have configured TAF, in out example sales3'sales3.us.example.comcom'
is such a service.
Service can be created with the DBMS_SERVICE package but in most cases they are created by some additional tools like Oracle Real Application Cluster. One can display the services created by the RAC for a database salesdb'salesdb' by executing the following comandcommand on the database server
The folowingfollowing output (that depends on the database version) shows that RAC will create a TAF service after start of the database
you can create a new service sales3'sales3.us.example.comcom' without TAF with the following command