VB.net updating Oracle record ExecuteNonQuery problem
-
27-10-2019 - |
Question
Hey all when i use TOAD to update a table all works just fine when using this query:
Update CSR.CSR_EAI_SOURCE ces
Set (STATUS_CODE, COMPLETE_DATE, DATA) =
(SELECT 'ERROR', '', REPLACE(REPLACE(c.Data, '…', ' '), '’','''')
FROM CSR.CSR_EAI_SOURCE C
WHERE c.EID = ces.EID
AND c.STATUS_CODE = 'ERROR')
WHERE EXISTS (SELECT 1
FROM CSR.CSR_EAI_SOURCE C
WHERE c.EID = ces.EID
AND c.STATUS_CODE = 'ERROR');
However, once i try doing the same thing in my VB.net program using this code:
Dim OracleCommand As New OracleCommand()
Dim ra As Integer
OracleCommand = New OracleCommand("UPDATE CSR.CSR_EAI_SOURCE ces " & _
"SET (STATUS_CODE, COMPLETE_DATE, DATA) = " & _
"(SELECT 'ERROR', '', REPLACE(REPLACE(c.Data, '…', ' ' ), '’','''') " & _
"FROM CSR.CSR_EAI_SOURCE C " & _
"WHERE (c.EID = ces.EID) " & _
"AND c.STATUS_CODE = 'ERROR') " & _
"WHERE EXISTS (SELECT 1 " & _
"FROM CSR.CSR_EAI_SOURCE C " & _
"WHERE (c.EID = ces.EID) " & _
"AND c.STATUS_CODE = 'ERROR')", OracleConnection)
Try
ra = OracleCommand.ExecuteNonQuery()
OracleConnection.Close()
MsgBox("done")
Catch ex As Exception
MsgBox("ERROR: " & Err.Description & " " & Err.Number)
OracleConnection.Close()
End Try
It stays on the ra = OracleCommand.ExecuteNonQuery() continuously until i get the error
The CLR has been unable to transition from COM context 0x3327fa8 to COM context 0x3328118 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
What could i do in order to get this working within VB.net since it works just fine in TOAD when running that same query?
Thanks!
David
Solution
you can also turn off that ContextSwitchDeadlock was detected exception:
To avoid these error popups from appearing, select Exceptions from the Debug menu from Visual Studio window and in the Exception Dialog box select the Managed Debugging Assistants Exception Node. Then select ContextSwitchDeadlock and remove the select from Thrown column
from http://dotnetdud.blogspot.com/2009/01/clr-has-been-unable-to-transition-from.html
EDIT:Check for Locks
SELECT LPAD(' ',DECODE(l.xidusn,0,3,0)) || l.oracle_username "User Name",
o.owner, o.object_name, o.object_type
FROM v$locked_object l, dba_objects o
WHERE l.object_id = o.object_id
ORDER BY o.object_id, 1 desc;
do note you will need ability to see dba_objects as well as v$locked_object (pulled this from here)
and check out this article http://www.orafaq.com/node/854
OTHER TIPS
Looks like the query takes a very long time to execute, so the UI is blocking. The best solution would be to run this query in a different thread, so that it doesn't block the UI... or optimize your query so that it runs faster.