CREATE OR REPLACE FUNCTION get_table_activity_report
RETURN SYS_REFCURSOR
AS
l_cursor SYS_REFCURSOR;
TYPE t_table_stats IS RECORD (
table_name_col VARCHAR2(40),
rows_last_45_days NUMBER,
total_rows_approx NUMBER,
percentage_change NUMBER
);
TYPE t_table_stats_tab IS TABLE OF t_table_stats INDEX BY PLS_INTEGER;
l_results t_table_stats_tab;
v_idx PLS_INTEGER := 0;
BEGIN
-- ... (Your loop and logic remains the same, populating l_results)
FOR r IN (
SELECT table_name
FROM user_tab_columns
WHERE column_name = 'INTERNTIMESTAMP'
AND data_type LIKE 'TIMESTAMP%'
ORDER BY table_name
)
LOOP
-- ... (The inner DECLARE/BEGIN/END block populating v_cnt and v_total)
-- Store the results in the collection
-- ... (Store to l_results(v_idx))
END LOOP;
-- Open the cursor and return it
OPEN l_cursor FOR
SELECT
t.table_name_col AS TABLE_NAME,
t.rows_last_45_days AS ROWS_LAST_45_DAYS,
t.total_rows_approx AS TOTAL_ROWS_APPROX,
t.percentage_change AS PCT
FROM TABLE(CAST(l_results AS t_table_stats_tab)) t;
RETURN l_cursor;
EXCEPTION
WHEN OTHERS THEN
-- Handle global errors if needed
RAISE;
END get_table_activity_report;
/
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)