I am executing a DDL from inside a stored proc :
v_sql_stmt := 'ALTER INDEX PK_TEST REBUILD ONLINE';
EXECUTE IMMEDIATE (v_sql_stmt);
All objects - the index, the table (on which the index is built), and the proc (with the above 2 lines) belong to the same schema. Also, while executing the stored proc, I am logging into that same schema and executing the proc as the owner.
However, every time I run it, I am getting the error : ORA-01031: insufficient privileges for this statement
I have had the DBA grant CREATE ANY TABLE and CREATE ANY INDEX privileges explicitly to the user, because the PL/SQL may not be able to resolve the grants given via roles.
But am still getting the error in this line after the grants. The other parts of the proc is executing OK, as I can see from dbms_output tracing at various points.
Can anyone please help with ideas ?