Scenario : we have an application that uses Oracle 10g and the latest version of ODP.net in an ASP.net application. We use the .ClientID WriteOnly property for the OracleConnection object to pass a specific user ID to the database for audit purposes. When the connection pool is disconnected, this works fine.
When it is turned on, the first user who logs in (for example, USER1) updates the record, and MODIFIED_BY is USER1, but when another user goes to the website after, thus capturing the connection in the pool, MODIFIED_BY remains USER1, despite to enter the system. USER2 for ClientID.
The logic of our database is as follows:
We save the class in an ASP.net session that has the logic for connecting to the database. At the first call, this is our constructor:
Public Sub New(ByVal connection As String, Optional ByVal oracleClientID As String = "") MyBase.New() _oracleConnection = New OracleConnection(connection) _clientID = oracleClientID End If End Sub
Here is the gist of the code to open the connection and close, get rid of:
Try _OraCmd = New OracleCommand(command, _oracleConnection) With _OraCmd .BindByName = True .Parameters.Clear() .CommandType = CommandType.StoredProcedure _oracleConnection.Open() If _clientID <> "" Then _oracleConnection.ClientId = _clientID Dim OraDadpt As New OracleDataAdapter(_OraCmd) '' Logic to get data OraDadpt.Fill(ds) End With Catch ex As Exception Throw ex Finally ClearParameters() _OraCmd.Dispose() _oracleConnection.Close() End Try
The point is that since the connection is in the pool, an alleged LOGON trigger is called, which never happens, and the client ID is never set again. However, the ORACLE documentation says that ClientID is used exactly for what we are trying to do.
Does anyone have any thoughts on why SYS_CONTEXT ('USERENV', 'CLIENT_IDENTIFIER') is not given a new USERID, which is passed to ClientID when the connection pool is used in our .NET application with ODP.net? Is it a database setup, a listener setup?
Update
We sent the question to Oracle. At the same time, we had to create a small test application that simulated a problem. At the same time, everything worked fine on my local host using the built-in Cassini web server in Visual Studio. With IIS, a problem arises.
UPDATE
Determined that IIS is not a problem. Package variables were not cleared because the connections that were merged were reused, essentially what the pool should do. We solved this with DBMS_SESSION.MODIFY_PACKAGE_STATE (DBMS_SESSION.REINITIALIZE).