|
-
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
-
Too many issues, let me address the first couple of them...
1- Are you sure you have the right Create Index syntax?
2- Are you sure you do not have any composite index?
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
-
Hi PAVB
1. Syntax is just perfect. It runs without any error in another database.
2. Its a single column index.
I even compared table and system privileges for the user on both dbs, but to find no differences at all.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|