以下是一些应该从任意长度的 LONG 输出 CLOB 的代码。它转储MY_TRIGGER
to的主体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;
/