创建表:
create table TB_TEST ( ID NUMBER not null, COLUMNID NUMBER not null, TITLE VARCHAR2(100) not null, CONTENT CLOB not null, CREATETIME DATE default SYSDATE not null ) |
存储过程:
create or replace procedure PROC_TEST_ADD ( i_title in varchar2, i_columnId in number, i_content in clob, o_id out number ) is v_content clob; v_buffer varchar2(512); v_length number := 0; v_offset number := 1; v_amount number := 256; begin select seq_test.nextval into o_id from dual; insert into tb_test ( id, columnid, title, content, createtime ) values ( o_id, i_columnid, i_title, empty_clob(), sysdate ); 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 = o_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_ADD; |
Insert函数:
public void Insert() string str = "跨世纪发的司法考试方"; command = new OracleCommand("PROC_TEST_ADD",connection); command.ExecuteNonQuery(); |