方法二:使用DBMS_LOB.SUBSTR和DBMS_LOB.CONVERTTOCLOB 对于较大的BLOB数据,你可以先将其转换为CLOB,然后逐步读取CLOB并将其转换为字符串。 plsql DECLARE l_blob BLOB; l_clob CLOB; l_offset NUMBER := 1; l_amount NUMBER := 32767; l_buffer VARCHAR2(32767); BEGIN -- 从表中获取BLOB数据 SELECT b...
public String ConvertBLOBtoString(java.sql.Blob BlobContent) { byte[] base64; String newStr = ""; //返回字符串 try { base64=org.apache.commons.io.IOUtils.toByteArray(BlobContent.getBinaryStream()); newStr=new BASE64Encoder().encodeBuffer(base64); } catch (IOException e) { e.printStac...
v_string := TO_CHAR(v_clob); DBMS_OUTPUT.PUT_LINE('CLOB as string: ' || v_string); END; 四、使用DBMS_LOB.CONVERTTOCLOB函数 DBMS_LOB.CONVERTTOCLOB函数可以将BLOB或NCLOB类型的数据转换为CLOB类型的数据。我们可以先将CLOB转换为BLOB,然后再转换为字符串。 使用DBMS_LOB.CONVERTTOCLOB函数将CLOB转...
可以返回这个图片的临时路径,类似如下:前端接口请求的时候,设置responseType: 'blob',后端接口直接返回的...
public static String ConvertBLOBtoString(oracle.sql.BLOB BlobContent) { byte[] msgContent= BlobContent.getBytes(); //BLOB转换为字节数组 byte[] bytes; //BLOB临时存储字节数组 String newStr = ""; //返回字符串 int i=1; //循环变量 long BlobLength; //BLOB字段长度 ...
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); cmd.Parameters["PHOTO"].Value = MyData; try { int result = cmd.ExecuteNonQuery(); if(result<1) { OleDbCommand cmd1 = new OleDbCommand(" INSERT INTO BLOB (PHOTO) VALUES ( ? )",cn); ...
在上述代码中,首先使用SELECT语句将CLOB字段的值读取到l_clob_data变量中。然后,使用DBMS_LOB.CONVERTTOBLOB函数将CLOB字段转换为BLOB字段,并将结果赋值给l_blob_data变量。最后,使用UTL_RAW.CAST_TO_VARCHAR2函数将BLOB字段转换为字符串,并将结果赋值给l_string变量。
//Ocom.Parameters.Add(new OracleParameter("picture",OracleType.Blob)); Ocom.Parameters["emp_id"].Value=Convert.ToDecimal(tbempid.Text); Ocom.Parameters["emp_no"].Value=tbempno.Text; Ocom.Parameters["emp_desc"].Value=tbempdesc.Text; ...
So, we want to store the data as BLOB. The datas in the binaries files are in double format. But, we have to convert the current datas in the database from CLOB to BLOB. We don't want to use the procedure DBMS_LOB.converttoblob because we obtain ASCII format datas. In the B...
fsBlob.Read(dataBlob,0,System.Convert.ToInt32(fsBlob.Length));//问题2所在 fsBlob.Close(); //采用新的方法,AddWithValue(); cmd.Parameters.AddWithValue("blob", dataBlob); //cmd.Parameters["blob"].Value = dataBlob; intresult=cmd.ExecuteNonQuery(); ...