Hello,
I am trying to retrieve a BLOB value from a oracle database using a stored procedure with output parameters(parm). Here is the piece of code where I do this.
using (DbCommand cmd = db.GetStoredProcCommand(sStoredProcName))
{
cmd.Connection = conn;
AttachParameters(db, cmd, lParamValueList);
if (idbTransaction != null)
{
db.ExecuteNonQuery(cmd, idbTransaction);
}
else
{
db.ExecuteNonQuery(cmd);
}
GetReturnValues(db, conn, cmd, ref lParamValueList);
}
And then under GetReturnValues there is another calling function, the piece of troubled code is
cmd.Connection = conn;
if (db != null && cmd != null && (Out || IsReturnValue))
{
int iIndex = ((Oracle.DataAccess.Client.OracleCommand)cmd).Parameters.IndexOf(ParamName);
if (iIndex >= 0)
{
Oracle.DataAccess.Client.OracleParameter parm = (((Oracle.DataAccess.Client.OracleCommand)cmd).Parameters[iIndex]);
if (conn.State == ConnectionState.Closed)
conn.Open();
Oracle.DataAccess.Types.OracleBlob blob = new Oracle.DataAccess.Types.OracleBlob((Oracle.DataAccess.Client.OracleConnection)conn);
blob = (Oracle.DataAccess.Types.OracleBlob)parm.Value;
if (blob.Length > 0)
{
byte[] bytes = new byte[blob.Length];
blob.Read(bytes, 0, (int)blob.Length);
ReturnValueBytes = bytes;
}
...
Everything seems to working fine unless the it reaches the line of the code where I am setting the output parameter value to a ORACLEBLOB variable. I understand that the ORACLE BLOB requires the connection to be opened explicitly. Till the troubled line the BLOB connection state is open and as soon as it passes
blob = (Oracle.DataAccess.Types.OracleBlob)parm.Value
the state of the connection inside the BLOB variable is closed.
I am not able to understand why is this happening. Any hints or help would be much appreciated.
Thanks,
Deepak