Error 8/40 PLS-00364: loop index variable ‘I’ use is invalid

oracleplsql

When I execute this stored procedure:

create or replace procedure "delete-archive"
is 
begin
for i in (select * from table(RDSADMIN.RDS_FILE_UTIL.LISTDIR('DATA_PUMP_DIR'))
    where FILENAME like 'JDE%')
    loop
    UTL_FILE.FREMOVE ('DATA_PUMP_DIR', i.filename );
    end loop;
end;

I get this error:

8/40 PLS-00364: loop index variable 'I' use is invalid

The owner has execute permission. It was like that GRANT DBA TO pqp;. Do you think that the problem may be permissions?

Best Answer

Answers originally left as comments:


Gerard H. Pille: A stored procedure can't use permissions granted via a role. You need:

GRANT EXECUTE ON RDSADMIN.RDS_FILE_UTIL TO PQP

Albert Godfrind: As an aside, granting DBA to a regular user or application is a very bad idea. It should only ever be granted to an actual DBA account.