public static void WriteLob(string table_namestring table_idint idint columnstring content)
{
OracleConnection myCn = new OracleConnection(strConn);
OracleCommand myCmd = new OracleCommand();
try
{
myCnOpen();
}
catch(SystemDataOracleClientOracleException e)
{
throw new Exception(eMessage);
}
OracleTransaction myTrans = myCnBeginTransaction();
try
{
myCmdConnection = myCn;
myCmdTransaction = myTrans;
myCmdCommandText = SELECT * FROM + table_name + where + table_id + = + id + FOR UPDATE;
OracleDataReader reader = myCmdExecuteReader();
using(reader)
{
readerRead();
OracleLob CLOB = readerGetOracleLob(column);//column为lob类型所在列
Encoding UTF = EncodingUTF;//使用UTF进行编码
byte[] buffer= UTFGetBytes(content);
if(bufferLength % ==)
CLOBWrite(buffer bufferLength); //这里的参数必须为偶数
else
CLOBWrite(buffer (bufferLength ));
//CLOBPosition= ;
myTransCommit();
}
}
catch(SystemDataOracleClientOracleException e)
{
myTransRollback();
throw new Exception(eMessage);
}
finally
{
myCmdDispose();
myCnClose();
}
}
public static string ReadLob(string table_namestring table_idint idint column)
{
OracleConnection myCn = new OracleConnection(strConn);
OracleCommand myCmd = new OracleCommand();
try
{
myCnOpen();
}
catch(SystemDataOracleClientOracleException e)
{
throw new Exception(eMessage);
}
OracleTransaction myTrans = myCnBeginTransaction();
try
{
myCmdConnection = myCn;
myCmdTransaction = myTrans;
myCmdCommandText = SELECT * FROM + table_name + where + table_id + = + id + FOR UPDATE;
OracleDataReader reader = myCmdExecuteReader();
using(reader)
{
readerRead();
OracleLob CLOB = readerGetOracleLob(column);
int[] content = new int[(int)CLOBLength];
byte[] buffer = new byte[(int)CLOBLength];
for(int i = ;i<(int)CLOBLength;i++)
{
content = CLOBReadByte();
buffer= (byte)content;
}
Encoding utf = EncodingUTF;
string final = utfGetString(buffer);
myTransCommit();
return final;
}
}
catch(SystemDataOracleClientOracleException e)
{
myTransRollback();
throw new Exception(eMessage);
}
finally
{
myCmdDispose();
myCnClose();
}
}