如何使用Oracle.DataAccess将9 MB文件插入Blob字段?

时间:2010-05-14 18:11:21

标签: vb.net oracle odp.net

尝试将大型音频文件插入Oracle 10g数据库并继续收到此错误:

  

ORA-01460:请求未执行或无理转换

音频文件的字节数组长度为2702577.该过程适用于较小的数组长度,但不适用较大的数组。

这是我的代码,谢谢!

Dim oracleConnection As New OracleClient.OracleConnection
        Dim Cmd As New OracleClient.OracleCommand
        Dim oracleDataAdapter As New OracleDataAdapter

        oracleConnection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("MasterConnectionODT")
        Cmd.Connection = oracleConnection
        Cmd.CommandText = "Audio.ADD_AUDIO"
        Cmd.CommandType = CommandType.StoredProcedure

        Dim aParam As New OracleClient.OracleParameter
        aParam.ParameterName = "I_FACILITY_ID_C"
        aParam.OracleType = OracleType.Char
        aParam.Value = FacID
        aParam.Direction = ParameterDirection.Input
        Cmd.Parameters.Add(aParam)

        aParam = New OracleParameter
        aParam.ParameterName = "I_TARP_ID_N"
        aParam.OracleType = OracleType.Number
        aParam.Value = TarpID
        aParam.Direction = ParameterDirection.Input
        Cmd.Parameters.Add(aParam)

        aParam = New OracleParameter
        aParam.ParameterName = "I_AUDIO_BLOB"
        aParam.OracleType = OracleType.Blob
        aParam.Value = Audio
        aParam.Direction = ParameterDirection.Input
        Cmd.Parameters.Add(aParam)


        Using oracleConnection
            oracleConnection.Open()
            Cmd.ExecuteNonQuery()
        End Using

1 个答案:

答案 0 :(得分:0)

您不能将大于32k的参数传递到存储过程。将命令更改为SQL。所以它会是这样的:

Cmd.CommandText = "insert into yourtable values (:I_FACILITY_ID_C, :I_TARP_ID_N, :I_AUDIO_BLOB)"
Cmd.CommandType = CommandType.Text

如果您仍然遇到问题,请尝试使用ODP.Net(如果您还没有。)