DECLARE
v_search_string VARCHAR2 (2000) := 'SAMPLE_STRING';
v_fmla_name ff_formulas_f.formula_name%TYPE;
v_fmla_text CLOB;
CURSOR get_fmla
IS
SELECT fff.view_name
FROM dba_views fff;
FUNCTION long_to_varchar2 (
p_tab IN VARCHAR2,
p_long_col IN VARCHAR2,
p_view_name IN VARCHAR2
)
RETURN CLOB
IS
-- v_size = number of characters to retrieve
v_cur INTEGER;
v_rc INTEGER;
v_size INTEGER := 32000;
v_buffer VARCHAR2 (32000);
v_buf_len INTEGER;
BEGIN
v_cur := DBMS_SQL.open_cursor;
DBMS_SQL.parse (v_cur,
'SELECT '
|| p_long_col
|| ' FROM '
|| p_tab
|| ' WHERE view_name = :p_view_name',
DBMS_SQL.native
);
DBMS_SQL.bind_variable (v_cur, ':p_view_name', p_view_name);
DBMS_SQL.define_column_long (v_cur, 1);
v_rc := DBMS_SQL.execute_and_fetch (v_cur);
DBMS_SQL.column_value_long (v_cur, 1, v_size, 0, v_buffer, v_buf_len);
DBMS_SQL.close_cursor (v_cur);
RETURN SUBSTR (v_buffer, 1, v_buf_len);
END long_to_varchar2;
BEGIN
FOR rec IN get_fmla
LOOP
BEGIN
v_fmla_text :=
long_to_varchar2 ('DBA_VIEWS',
'TEXT',
rec.view_name
);
IF UPPER (v_fmla_text) LIKE '%' || UPPER (v_search_string) || '%'
THEN
DBMS_OUTPUT.put_line ( 'View '
|| rec.view_name
|| ' contains the string '
|| v_search_string
);
END IF;
-- EXCEPTION
END;
END LOOP;
--
--exception
END;
No comments:
Post a Comment