Home » SQL & PL/SQL » SQL & PL/SQL » ORA-01031: insufficient privileges (Oracle 11g, windows)
ORA-01031: insufficient privileges [message #614202] Mon, 19 May 2014 01:09 Go to next message
mokarem
Messages: 109
Registered: November 2013
Location: Dhaka
Senior Member

Hi All

I have created a package to return date range. Code of package body is as below:

create or replace package body gen_date_dim
is

function month_range( range_from date, range_to date) return date_tab
is 
 p_date_tab  date_tab;
 
begin
 
 select add_months(range_from, level-1)
 bulk collect into p_date_tab
 from dual
 connect by level <= months_between(range_to,range_from);
 
 return p_date_tab;
 
end month_range;
  
end gen_date_dim;


I created by the required TYPE also
create type date_tab is table of date


Now I want to create following view based on this package and type. The target view, package and TYPE are in same schema. But it is showing the error Insufficient privileges. How can I resolve this?

create or replace force  view dwh.v_dim_date
as
select column_value period_sid,
to_char(column_value,'YYYYMM') month_code,
to_char(column_value,'Mon YYYY') month_name,
'QTR'||to_char(column_value,'Q YYYY') quarter_name
from table(dwh.gen_date_dim.month_Range(to_date('01-jan-1900','dd-mon-yyyy'),to_date('01-dec-2100','dd-mon-yyyy')))


If I run the select statement separately, it can fetch the records:
select column_value period_sid,
to_char(column_value,'YYYYMM') month_code,
to_char(column_value,'Mon YYYY') month_name,
'QTR'||to_char(column_value,'Q YYYY') quarter_name
from table(dwh.gen_date_dim.month_Range(to_date('01-jan-1900','dd-mon-yyyy'),to_date('01-dec-2100','dd-mon-yyyy')))
Re: ORA-01031: insufficient privileges [message #614203 is a reply to message #614202] Mon, 19 May 2014 01:23 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

This means that somewhere there is something you have not the appropriate privilege to do this.
As you didn't post a complete session showing what you claim we can neither verify nor reproduce what you say.

So post the privileges and roles of the owner. And first are you sure it has been granted CREATE VIEW privilege?

And remove FORCE. Why do you use it?

Re: ORA-01031: insufficient privileges [message #614206 is a reply to message #614203] Mon, 19 May 2014 01:53 Go to previous messageGo to next message
mokarem
Messages: 109
Registered: November 2013
Location: Dhaka
Senior Member

Thanks Michel Cadot.

I have granted the 'CREATE VIEW' to my shcema(DWH) and then veiw has been created.

Actually I granted DBA role to this schema, so I thought 'CREATE VIEW' is not required separately.

Re: ORA-01031: insufficient privileges [message #614208 is a reply to message #614206] Mon, 19 May 2014 02:07 Go to previous message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Why did you grant DBA? Generally speaking, when you create a user, you should grant only minimal set of privileges. As it seems that you don't rally know which privileges are contained within precreated roles (such as DBA), pay attention to what you do - granting too much power can be dangerous. In your example, I don't see any reason why should that user be granted DBA (but I might be wrong).
Previous Topic: Oracle form error 06502
Next Topic: help with procedures!
Goto Forum:
  


Current Time: Fri Apr 19 17:19:58 CDT 2024