以下是一些應該從任意長度的LONG輸出CLOB的代碼。它將MY_TRIGGER
的主體轉儲到dbms_output
。如果它有效,你應該能夠根據需要進行解析。
DECLARE
c_chunk_limit CONSTANT INTEGER := 100;
v_cur INTEGER := DBMS_SQL.open_cursor;
v_offset INTEGER;
v_chunk VARCHAR2(32767);
v_chunk_size INTEGER;
BEGIN
DBMS_SQL.parse(
v_cur,
'SELECT trigger_body FROM dba_triggers WHERE trigger_name = ''MY_TRIGGER''',
DBMS_SQL.native
);
DBMS_SQL.define_column_long(v_cur, 1); -- 1 here represents the column position in the select list the long is column#1
IF DBMS_SQL.execute_and_fetch(v_cur) > 0
THEN
v_offset := 0;
LOOP
DBMS_SQL.column_value_long(
v_cur,
1, -- 1 here represents the column position in the select list the long is column#1
c_chunk_limit,
v_offset,
v_chunk,
v_chunk_size
);
EXIT WHEN v_chunk_size = 0;
v_offset := v_offset + v_chunk_size;
DBMS_OUTPUT.put_line(v_chunk);
END LOOP;
END IF;
DBMS_SQL.close_cursor(v_cur);
END;
/
long已過時,請使用clob或新的xml類型。 – tuinstoel 2009-08-01 16:21:11
@tuinstoel:請參閱文本中的註釋1。表格不能改變。例如, – DCookie 2009-08-01 21:02:22