OracleDataReader Exception when Select a Blob type Column

吃可爱长大的小学妹 提交于 2020-04-17 22:51:57

问题


I'm attempting to retrieve an EmptyBLOB from an Oracle database to next write a byte array on that column but I keep getting an Exception Message "ORA-03135: Connection lost contact" in the oracle Data Reader when ExecuteReader. If I select any other column of the table in the statement it works fine. The oracle database is 10g 10.2.0.4.0 - 64bit and I'm using the Oracle.ManagedDataAccess as ODP for .NET

oracleConnection.Open();
OracleCommand nameFile = oracleConnection.CreateCommand();
nameFile.Connection = oracleConnection;
nameFile.Transaction = nameFile.Connection.BeginTransaction();
nameFile.CommandText = "Delete from CF2 WHERE COMPANY_EMPID_FOLIO = :pCOMPANY_EMPID_FOLIO";
nameFile.Parameters.Add("pCOMPANY_EMPID_FOLIO", OracleDbType.Varchar2, 15).Value = sFolio;
nameFile.ExecuteNonQuery();
nameFile.CommandText = "insert into CF2 (COMPANY_EMPID_FOLIO, XML_AND_PDF_ZIP, CREATED_DATE, CREATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_BY) values(:pCOMPANY_EMPID_FOLIO,EMPTY_BLOB(), sysdate, :pUser, sysdate, :pUser)";
nameFile.Parameters.Add("pUser", OracleDbType.Varchar2, 10).Value = sUser;
nameFile.ExecuteNonQuery();
nameFile.Parameters.Clear();

nameFile.CommandText = "SELECT COMPANY_EMPID_FOLIO, XML_AND_PDF_ZIP FROM CF2 WHERE COMPANY_EMPID_FOLIO = :pCOMPANY_EMPID_FOLIO FOR UPDATE"; // XML_AND_PDF_ZIP is BLOP Type Column
nameFile.Parameters.Add("pCOMPANY_EMPID_FOLIO", OracleDbType.Varchar2, 15).Value = sFolio;
OracleDataReader oracleDataReader = nameFile.ExecuteReader(); //DB Lost Contact in this point if a include the blop column in the Select
OracleDataReader oracleDataReader1 = oracleDataReader;

try
{
    oracleDataReader.Read();
    OracleLob oracleLob = oracleDataReader.GetOracleLob(1);
    oracleLob.Write(bytes, 0, (int)bytes.Length);
}
finally
{
    if (oracleDataReader1 != null)
    {
        ((IDisposable)oracleDataReader1).Dispose();
    }
}

Is there something else I'm missing before the .read method ?

来源:https://stackoverflow.com/questions/60104421/oracledatareader-exception-when-select-a-blob-type-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!