Update Clob字段 SP最终版
1PROCEDURE INVHL_UPDATE_CLOB_DATA(
2 p_table_name IN VARCHAR2,
3 p_clob_field_name IN VARCHAR2,
4 p_where_condition IN VARCHAR2,
5 p_position IN NUMBER,
6 p_clob_data IN VARCHAR2 )
7/*表名table_name,
8clob字段名field_name
9确定要更新唯一记录的where条件p_where_condition
10开始处理字符的位置p_position,
11传入的字符串变量P_clob_data*/
12IS
13 v_lobloc CLOB;
14 v_clob_data VARCHAR2( 32767 );
15 v_amount BINARY_INTEGER;
16 v_position BINARY_INTEGER;
17 v_query_string VARCHAR2( 1000 );
18BEGIN
19 v_position := p_position * 32766 + 1;
20 v_amount := LENGTH( p_clob_data );
21 v_clob_data := p_clob_data;
22 v_query_string :=
23 'SELECT '
24 || p_clob_field_name
25 || ' FROM '
26 || p_table_name
27 || ' WHERE '
28 || p_where_condition
29 || ' FOR UPDATE';
30 dbms_output.put_line(v_query_string);
31 --initialize buffer with data to be inserted or updated
32 EXECUTE IMMEDIATE v_query_string
33 INTO v_lobloc;
34
35 --from pos position, write 32766 varchar2 into lobloc
36 DBMS_LOB.WRITE( v_lobloc,
37 v_amount,
38 v_position,
39 v_clob_data );
40 COMMIT;
41EXCEPTION
42 WHEN OTHERS THEN
43 ROLLBACK;
44END;
2 p_table_name IN VARCHAR2,
3 p_clob_field_name IN VARCHAR2,
4 p_where_condition IN VARCHAR2,
5 p_position IN NUMBER,
6 p_clob_data IN VARCHAR2 )
7/*表名table_name,
8clob字段名field_name
9确定要更新唯一记录的where条件p_where_condition
10开始处理字符的位置p_position,
11传入的字符串变量P_clob_data*/
12IS
13 v_lobloc CLOB;
14 v_clob_data VARCHAR2( 32767 );
15 v_amount BINARY_INTEGER;
16 v_position BINARY_INTEGER;
17 v_query_string VARCHAR2( 1000 );
18BEGIN
19 v_position := p_position * 32766 + 1;
20 v_amount := LENGTH( p_clob_data );
21 v_clob_data := p_clob_data;
22 v_query_string :=
23 'SELECT '
24 || p_clob_field_name
25 || ' FROM '
26 || p_table_name
27 || ' WHERE '
28 || p_where_condition
29 || ' FOR UPDATE';
30 dbms_output.put_line(v_query_string);
31 --initialize buffer with data to be inserted or updated
32 EXECUTE IMMEDIATE v_query_string
33 INTO v_lobloc;
34
35 --from pos position, write 32766 varchar2 into lobloc
36 DBMS_LOB.WRITE( v_lobloc,
37 v_amount,
38 v_position,
39 v_clob_data );
40 COMMIT;
41EXCEPTION
42 WHEN OTHERS THEN
43 ROLLBACK;
44END;