//将clob变成字符串
        private string ConvertClobToString(OracleLob oralob)
        {
            int[] content = new int[(int)oralob.Length];
            byte[] buffer = new byte[(int)oralob.Length];
            for (int i = 0; i <= oralob.Length; i++)
            {
                oralob.Read(buffer, 0, (int)oralob.Length);
            }            Encoding utf = Encoding.Unicode;
            string strfinal = utf.GetString(buffer);
            return strfinal;
        }
我就是想把CLOB或者BLOB字段里的内容弄出来,字符串类型什么都可以,只要可以显示,字数统计都可以,现在这种方法非常慢,48条记录要将近一分钟时间。
请高手支招

解决方案 »

  1.   

    BLOB和数据量有关。另外它不是通过标准SQL语句来的。所以会有些慢。
      

  2.   

    看看dbms_lob包,也许你可以用上.
    SQL> create table test_clob
      2  (id number(10),
      3   name clob);
     
    Table created
     
    SQL> insert into test_clob values(1,to_clob('1234567890'));
     
    1 row inserted
     
    SQL> commit;
     
    Commit complete
     
    SQL> select t.id,dbms_lob.substr(t.name) from test_clob t;
     
             ID DBMS_LOB.SUBSTR(T.NAME)
    ----------- --------------------------------------------------------------------------------
              1 1234567890
     
    SQL> select t.id,dbms_lob.getlength(t.name) from test_clob t;
     
             ID DBMS_LOB.GETLENGTH(T.NAME)
    ----------- --------------------------
              1                         10
     
    SQL>