本文主要是介绍c#处理oracle clob(二)——update,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
存储过程:
create or replace procedure PROC_TEST_UPD ( i_id in number, i_content in clob ) is v_content clob; v_buffer varchar2(512); v_length number := 0; v_offset number := 1; v_amount number := 256; begin update tb_test set content = empty_clob() where id = i_id; dbms_output.put_line(v_length); v_length := dbms_lob.getlength(i_content); dbms_output.put_line(v_length); select content into v_content from tb_test where id = i_id for update; dbms_lob.open(v_content,dbms_lob.lob_readwrite); while v_offset <= v_length loop dbms_lob.read(i_content,v_amount,v_offset,v_buffer); dbms_lob.writeappend(v_content,v_amount,v_buffer); v_offset := v_offset + v_amount; end loop; dbms_lob.close(v_content); commit; end PROC_TEST_UPD;
|
Update函数:
public void Update() { string sConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["wuyou"].ConnectionString; OracleConnection connection = null; OracleCommand command = null; try { connection = new OracleConnection(sConnectionString); connection.Open(); string str = ""; while (str.Length < 5000) { str += "春节快到了团聚访友放鞭炮高高兴兴过新年"; } command = new OracleCommand("PROC_TEST_UPD", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("i_id", OracleType.Number); command.Parameters["i_id"].Direction = ParameterDirection.Input; command.Parameters["i_id"].Value = 30; command.Parameters.Add("i_content", OracleType.Clob); command.Parameters["i_content"].Direction = ParameterDirection.Input; command.Parameters["i_content"].Value = str; command.ExecuteNonQuery(); } finally { if (command != null) { command.Dispose(); } if (connection != null) { connection.Dispose(); connection.Close(); } } } |
这篇关于c#处理oracle clob(二)——update的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!