Won't let create/replace a procedure
Hello all
This create proc snippet is driving me crazy as I have been trying to run it since 1 hr back.
Code:
CREATE OR REPLACE PROCEDURE sp_execndx1 IS
vsql VARCHAR2(3000);
BEGIN
FOR i IN (
SELECT index_name iname,table_name tblname,column_name cname,Decode(Trim(index_type),'BTREE','','BITMAP')itype,Decode(Trim(uniqueness),'NONUNIQUE','','UNIQUE')iunq FROM sp_master.m_indexes WHERE position=1
)
LOOP
BEGIN
vsql := 'CREATE '||i.iunq||' '||i.itype ||' INDEX '||i.iname||' ON '||i.tblname||'('||i.cname||') COMPUTE STATISTICS';
EXECUTE IMMEDIATE vsql;
EXCEPTION WHEN OTHERS THEN
SP_GETERRORS('I',SQLCODE,SQLERRM,vsql);
END;
END LOOP;
END;
/
It is throwing following error msg:
Create procedure, executed in 0.781 sec.
PL/SQL: ORA-01031: insufficient privileges
pl/SQL: SQL Statement ignored
PLS-00364: loop index variable 'I' use is invalid
PL/SQL: Statement ignored
Total execution time 3.063 sec.
I have granted all the required privileges to this user like create/drop any procedure, select on sp_master.m_indexes etc. Still it won't let me run this snippet. Could you please advise what I am missing out here?
Thanks,
gtcol