Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Problems With Using V$SESSION Procedure

Re: Problems With Using V$SESSION Procedure

From: John Findlay <john_findlay_at_non.agilent.com>
Date: Mon, 12 Aug 2002 19:14:56 +0100
Message-ID: <3D57FB20.3000201@non.agilent.com>


Salaam Yitbarek wrote:
> Hi,
>
> The following anonymous compiles:
>
> declare
> a v$session.SID%type;
> begin
> select min(SID) into a from v$session;
> dbms_output.put_line(a);
> end;
>
> However, take the above and put it in a stored procedure, and it does
> not compile, giving the error "PLS-00201: identifier 'V$SESSION' must
> be declared":
>
> create or replace procedure foo is
> a v$session.SID%type;
> begin
> select min(SID) into a from v$session;
> dbms_output.put_line(a);
> end;
>
> Now this problem occurs only with the V$ views, but not with other
> system tables or views such as ALL_ARGUMENTS, ALL_TABLES, etc.
>
> The above code was compiled under an account that has been assigned
> the DBA.
>
> Help?!
>
> Thanks,
> Salaam

Hi, your problem is because when you execute a stored procedure, the owner of the procedure must have DIRECTLY granted privileges on the objects referenced in the procedure. Privileges granted via a role e.g. select on v$session is granted via the SELECT_CATALOG_ROLE which is granted to the DBA role which is granted to your user will work for SQL but not for stored procedures. Grant select on the relevant tables directly to the user concerned an the procedures will be fine.

Have a look at the "PL/SQL User's Guide and Reference" in the Oracle manuals.

Regards

John S Findlay Received on Mon Aug 12 2002 - 13:14:56 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US