OracleDataReader 中的 REF CURSOR 参数
此 Visual Basic 示例执行一个 PL/SQL 存储过程,返回 REF CURSOR 参数,并将值作为 OracleDataReader 读取。
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim connString As New String("...")
Using conn As New OracleConnection(connString)
Dim cmd As New OracleCommand()
Dim rdr As OracleDataReader
conn.Open()
cmd.Connection = conn
cmd.CommandText = "CURSPKG.OPEN_ONE_CURSOR"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New OracleParameter(
"N_EMPNO", OracleType.Number)).Value = 7369
cmd.Parameters.Add(New OracleParameter(
"IO_CURSOR", OracleType.Cursor)).Direction = ParameterDirection.Output
rdr = cmd.ExecuteReader()
While (rdr.Read())
REM do something with the values
End While
rdr.Close()
End Using
End Sub