VB.net更新Oracle记录ExecuteNonQuery问题
大家好,当我使用 TOAD 更新表时,使用此查询时一切正常:
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');
但是,一旦我尝试使用此代码在 VB.net 程序中执行相同的操作:
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
它保留在 ra = OracleCommand.ExecuteNonQuery 上() 连续直到出现错误
CLR 在 60 秒内无法从 COM 上下文 0x3327fa8 转换到 COM 上下文 0x3328118。拥有目标上下文/单元的线程很可能执行非泵送等待或处理非常长时间运行的操作而不泵送 Windows 消息。这种情况通常会对性能产生负面影响,甚至可能导致应用程序变得无响应或内存使用量随着时间的推移不断累积。为了避免此问题,所有单线程单元 (STA) 线程都应使用泵送等待原语(例如 CoWaitForMultipleHandles),并在长时间运行的操作期间定期泵送消息。
我该怎么做才能让它在 VB.net 中工作,因为它在运行相同的查询时在 TOAD 中工作得很好?
谢谢!
大卫
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以关闭检测到 ContextSwitchDeadlock 异常:
从 http:// 的 dotnetdud.blogspot.com/2009/01/clr-has-been-unable-to-transition-from.html
编辑:检查锁
请注意,您需要能够查看 dba_objects以及 v$locked_object (从 此处 提取此内容) )
并查看这篇文章
http://www.orafaq.com/node/854
you can also turn off that ContextSwitchDeadlock was detected exception:
from http://dotnetdud.blogspot.com/2009/01/clr-has-been-unable-to-transition-from.html
EDIT:Check for Locks
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
看起来查询需要很长时间才能执行,因此 UI 被阻塞。最好的解决方案是在不同的线程中运行此查询,这样它就不会阻塞 UI...或优化您的查询以使其运行得更快。
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.