First of all I would like to say Hi to everyone here.
I have a procedure which I want to delete several records from several tables. Those tables from were I want to delete rows have names stored in another table in database along with the column name that is used for condition.
Main table DB_CLEANUP_PARAMETERS (the one that stores tables names for other) is like this:
I wrote the following procedure to do the things
Main problem is that I get the following error:
CREATE OR REPLACE PROCEDURE DB_CLEANUP_PROCEDURE_2 IS
TYPE j IS TABLE OF ROWID;
v_chunk_size INTEGER := 1000;
FOR rec IN (SELECT dcp.table_name, dcp.date_field_name, dcp.retention_days
FROM db_cleanup_parameters dcp) LOOP
v_table_name := rec.table_name;
v_column_name := rec.date_field_name;
v_retention_days := rec.retention_days;
EXECUTE IMMEDIATE 'SELECT ROWID FROM ' || v_table_name || ' WHERE ' ||
v_column_name || ' < (SYSDATE - ' || v_retention_days || ')'
BULK COLLECT INTO row_id;
FORALL i IN 1 .. row_id.COUNT()
EXECUTE IMMEDIATE 'DELETE FROM '||v_table_name||' WHERE ROWID = '''|| row_id(i)||''' AND ROWNUM <='||v_chunk_size;
EXIT WHEN SQL%ROWCOUNT = 0;
Purpose of this procedure is to delete rows from the tables stored in DB_CLEANUP_PARAMETER table, but not one by one. Delete rows in chunks.
Compilation errors for PROCEDURE ONAIR.DB_CLEANUP_PROCEDURE_2
Error: PLS-00801: internal error [*** ASSERT at file pdw4.c, line 589; Unknown expression Expr = 283.; DB_CLEANUP_PROCEDURE_2__ONAIR__P__287291[20, 5]]
Text: EXECUTE IMMEDIATE 'DELETE FROM '||v_table_name||' WHERE ROWID = '''|| row_id(i)||''' AND ROWNUM <='||v_chunk_size;
What is wrong ? can I get some help ?