在 VB.NET 中使用 dbms_output.get_line
我有一些要执行的存储过程,它们使用 dbms_output.put_line() 来将数据放入输出缓冲区。
我知道我需要使用 dbms_output.get_line(:line, :status) 来检索该输出。 我使用 System.Data.OracleClient 来避免 Oracle 部署带来的麻烦。
那么我下面的代码做错了什么?
Dim cmdSproc As OracleCommand = cnOracle.CreateCommand()
Dim strOracle As New OracleString()
Dim opaLine As New OracleParameter("lineOut", OracleType.VarChar, 255)
opaLine.Direction = ParameterDirection.Output
Dim opaStatus As New OracleParameter("status", 0)
cmdSproc.CommandText = "begin dbms_output.get_line(:lineOut,:status); end;"
cmdSproc.Parameters.Add(opaLine)
cmdSproc.Parameters.Add(opaStatus)
Dim strOutput As String = ""
strOracle = "0"
Try
While strOracle = "0"
cmdSproc.ExecuteOracleNonQuery(strOracle)
strOutput = strOutput & strOracle.ToString() & vbNewLine
End While
Catch ex As Exception
MsgBox(ex.Message)
End Try
I have some stored procedures to execute that use dbms_output.put_line()
to put data into the output buffer.
I know I need to use dbms_output.get_line(:line, :status)
to retrieve that output.
I'm using System.Data.OracleClient
to avoid headaches with Oracle deployment.
So what am I doing wrong with the code below?
Dim cmdSproc As OracleCommand = cnOracle.CreateCommand()
Dim strOracle As New OracleString()
Dim opaLine As New OracleParameter("lineOut", OracleType.VarChar, 255)
opaLine.Direction = ParameterDirection.Output
Dim opaStatus As New OracleParameter("status", 0)
cmdSproc.CommandText = "begin dbms_output.get_line(:lineOut,:status); end;"
cmdSproc.Parameters.Add(opaLine)
cmdSproc.Parameters.Add(opaStatus)
Dim strOutput As String = ""
strOracle = "0"
Try
While strOracle = "0"
cmdSproc.ExecuteOracleNonQuery(strOracle)
strOutput = strOutput & strOracle.ToString() & vbNewLine
End While
Catch ex As Exception
MsgBox(ex.Message)
End Try
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在vb.net中SKINDER朋友的代码格式如下...感谢分享
In vb.net the code format SKINDER friend is as follows... thnxs for sharing
这是我如何让它工作的:(发现它此处)
Here's how I got it to work: (found it here)
在 C# 中,我使用下一个方法:
In C# I am using the next method: